Skip to content

360 Spin

By , Customer Success DirectorUpdated

Open this page in a new chat

Short answer

Paste the sirv.js script into your page, then a div with the class Sirv and the URL of your .spin file in data-src. Over 30 options control when the images load, how the spin turns, the hint, autospin, zoom and fullscreen. Apply them in the div with data-options or for every spin in a script.

After reading this you will know

  • How to embed a 360 spin with Sirv Media Viewer
  • Which options control loading, turning, hint and autospin
  • How to style the spin and set mobile options

The 360 spin module of Sirv Media Viewer, part of Sirv JS v3 (the latest version), lets customers examine your products from every angle.

It harnesses the full power of Sirv’s dynamic imaging, allowing you to provide exceptional user experience for your customers.

Sirv Media Viewer can embed one 360 spin, many spins or a mixture of spins, images, zooms and videos.

The code is:

<div class="Sirv" data-src="https://demo.sirv.com/tshirt-aqua.spin"></div>

This gallery contains many spins, swappable by thumbnails underneath:

The code is:

<div class="Sirv">
<div data-src="https://demo.sirv.com/tshirt-aqua.spin"></div>
<div data-src="https://demo.sirv.com/tshirt-red.spin"></div>
<div data-src="https://demo.sirv.com/tshirt-grey.spin"></div>
<div data-src="https://demo.sirv.com/tshirt-blue.spin"></div>
<div data-src="https://demo.sirv.com/tshirt-green.spin"></div>
</div>

It’s easy to embed Sirv Media viewer in your page.

1. Paste this script anywhere in your HTML (typically before the </head> or </body> tag):

<script src="https://scripts.sirv.com/sirvjs/v3/sirv.js"></script>

If you only need Sirv JS for 360 spins, you can use a smaller version of Sirv JS instead.

2. Add a div with the class “Sirv”. Place each spin, image or video in its own div. The following example contains one spin, one zoomable image and one video.

Thumbnails will be automatically generated, to swap between the 3 assets:

<div class="Sirv">
<div data-src="https://demo.sirv.com/example.spin"></div>
<div data-src="https://demo.sirv.com/example.jpg" data-type="zoom"></div>
<div data-src="https://demo.sirv.com/videos/e-tron_quattro.mp4"></div>
</div>

See examples of mixed assets on the Sirv Media Viewer page.

Customize your spin with 30+ options.

ParameterDefaultOptionsDescription
initializeloadload, hover, clickWhen to start downloading images.
inactivity3000numeric (ms)Wait time before spin considered inactive.
spin.speed3600numeric (ms)Time to complete 1 full rotation.
column.start1Frame number of first image shown on load.
column.looptruetrue, falseLoop between first and last frame.
column.increment1numericNumber of frames to jump when spinning.
column.reversefalsetrue, falseChange direction of spin.
column.sensitivity501-100Speed of spin when dragging.
row.start1Number of first frame to show after load.
row.loopfalsetrue, falseLoop after last frame to next row.
row.increment1numericNumber of frames to jump when spinning.
row.reversefalsetrue, falseChange direction of spin.
row.sensitivity501-100Speed of spin when dragging.
wheelfalsetrue, falseRotate spin with mousewheel.
swapSidesfalsetrue, falseSwap rows and columns.
freeDragfalsetrue, falseSpin by dragging in any direction.
Autospin
autospin.enablefalsetrue, falseContinuously rotate the spin.
autospin.resume3000numeric (ms)Time before autospin resumes after interaction.
autospin.typespheresphere, row, fullStyle of autospin animation, for multi-row spins.
Hint
hint.message.enabletruetrue, falseShow hint that image is interactive.
hint.message.textDrag to spinText displayed in hint.
hint.onStart.enabletruetrue, falseShow hint once images have loaded.
hint.onStart.effectintrointro, twitch, spin, momentum, sphere, noneStyle of animation.
hint.onVisible.enabletruetrue, falseShow hint when spin becomes visible.
hint.onVisible.effecttwitchintro, twitch, spin, momentum, sphere, noneStyle of animation.
hint.onInactive.enabletruetrue, falseShow hint after period of inactivity.
hint.onInactive.effecttwitchintro, twitch, spin, momentum, sphere, noneStyle of animation.
Zoom
zoom.enabletruetrue, falseAllow zoom into image.
zoom.ratio2.5multipleMagnification level.
zoom.tilestruetrue, falseBreak zoomed image into tiles.
zoom.pantruetrue, falsePan the zoomed image on hover.

There are 2 ways to apply options - in the spins’ div or in a script.

Spin options can be applied in the div of the spin, with the data-options attribute. This example changes the inactivity period to 7000ms:

<div class="Sirv">
<div data-src="https://demo.sirv.com/example.spin" data-options="inactivity:7000"></div>
</div>

Spin options can also be applied with JavaScript either within the page or in an external JS file. The following example changes the hint text, autospin and speed:

<script>
var SirvOptions = {
viewer: {
spin: {
hint: {
message: {
text: 'Spin me!'
}
},
autospin: {
enable: true
},
speed: 6000
}
}
}
</script>

Your spin will automatically load all its images when it enters the viewport - known as lazy loading. Before then, only the first image loads.

This helps prevent a spin from loading images unnecessarily.

Alternatively, you can set initialize to either click or hover.

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="initialize:click"></div>
</div>

Load on click

Load on hover

Your spins will twitch every 3000ms (3 seconds) to indicate that they are interactive.

You can increase or decrease the inactivity period:

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="inactivity:7500"></div>
</div>

1500ms (1.5 seconds)

10000ms (10 seconds)

If your spin has a very large number of images, you may wish to load fewer images. It won’t feel as smooth but it will use less data transfer.

Apply the column.increment parameter with a value of 2 to show every other frame, 3 to show every third frame and so on.

<div class="Sirv">
<div data-src="https://demo.sirv.com/demo/chacos/chacos.spin" data-options="column.increment:4"></div>
</div>

Original (112 frames)

Column increment 4 (28 frames)

If you have a multi-row 3D spin, you can also change the row.increment.

The first image in your spin will show during and after load.

You can set a different first image with column.start. If you have a multi-row 3D spin, you can also change the row.start:

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="column.start:6; row.start:2"></div>
</div>

Column 7, row 1

Column 8, row 2

Column 11, row 3

After the last frame, spins automatically loop back to the first frame.

You can stop looping, which is desireable if your spin does not end where it began. Set the column.loop parameter to false:

<div class="Sirv">
<div data-src="https://demo.sirv.com/box.spin" data-options="column.loop:false"></div>
</div>

Loop disabled:

Multi-row spins do not loop by default, because they normally only have a few rows and don’t complete a full vertical 360. To loop rows, set row.loop to true.

The spin will rotate your frames in ascending order. Typically, spins feel most natural rotating in a clockwise direction.

If your frames are numbered in the opposite direction, you can reverse this.

To swap the direction, set the column.reverse parameter to true:

<div class="Sirv">
<div data-src="https://demo.sirv.com/box.spin" data-options="column.reverse:true"></div>
</div>

Original direction

Reverse direction

It’s also possible to reverse the vertical direction of a multi-row 3D spin by setting row.reverse to true.

The speed at which the spin rotates on drag is determined by the column.sensitivity and row.sensitivity parameters.

They are set to 50 by default, on a scale of 0-100. A lower value reacts more slowly and a higher value more quickly.

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="column.sensitivity:40; row.sensitivity:60"></div>
</div>

Low sensitivity, 30

High sensitivity, 70

The mousewheel will rotate a 3D spin up and down. You can disable this by setting wheel to false:

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="wheel:false"></div>
</div>

Mousewheel enabled

Mousewheel disabled

To help inform users that a spin is interactive, a ‘hint’ is shown. Hints are shown on load, when it comes into view and few seconds if the user doesn’t interact with it.

There are 6 effects to choose from by setting hint.onStart.effect, hint.onVisible.effect and/or hint.onInactive.effect:

  • intro - 1 full spin row, then left and right (default).
  • twitch - slight movement up, down, left and right.
  • spin - 1 full spin row.
  • momentum - 1 fast spin row.
  • sphere - 1 full spin row, then 1 full column.
  • none - no movement

Intro

Twitch

Spin

Momentum

Sphere

None

For example, apply the momentum effect like so:

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="hint.onStart.effect:momentum"></div>
</div>

The default text shown on the spin is “Drag to spin”. Change this by applying the hint.message.text, for example:

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="hint.message.text:Here is some text"></div>
</div>

Autospin can continually rotate the spin until the user interacts with it.

To enable autospin, set autospin.enable to true:

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="autospin.enable:true;"></div>
</div>

Autospin will restart 3 seconds after the user stops interacting with it. You can adjust this by setting the number of milliseconds (ms) in the autospin.resume option.

This example sets it to instantly resume (after 0ms):

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="autospin.enable:true; autospin.resume:0;"></div>
</div>

The default duration of one rotation is 3600ms. You can reduce this to speed up the spin or increase it to slow it down.

This spin completes each rotation in 1.5 seconds (1500ms):

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="spin.autospin.enable:true; spin.speed:1500"></div>
</div>

If you have a multi-row spin, you can use autospin.type to choose between 3 different rotation styles:

  • sphere - rotate 1 row then up and down (default style).
  • row - rotate 1 row.
  • full - rotate all rows.
<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="autospin.enable:true; autospin.type:full"></div>
</div>

Sphere

Row

Full

Users can click any frame to zoom in.

Zoom can be disabled by setting zoom.enable to false:

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="zoom.enable:false"></div>
</div>

The magnification level of the zoom is 2.5 times larger than the main image. This can be increased/decreased to show more/less detail with the zoom.ratio.

This would increase the zoom to 4.0 times magnification::

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="zoom.ratio:4.0"></div>
</div>

The zoomed image is generated from small square tiles of the large image, to help the image load quickly.

Instead, it is possible to load the zoom as one very large image with the zoom.tiles option:

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="zoom.tiles:false"></div>
</div>

The user can move around the zoomed image by panning their cursor/finger. This effect can be disabled by setting zoom.pan to false:

<div class="Sirv">
<div data-src="https://demo.sirv.com/boot.spin" data-options="zoom.pan:false"></div>
</div>

In case your spin file names contain row and column sequences that are back-to-front, you can use the swapSides parameter to switch them around. Set the option to true.

Fullscreen is initiated by double-clicking the spin or clicking the fullscreen icon in the top right. On mobile, you can also pinch out to trigger fullscreen.

To trigger fullscreen in one click, set fullscreen.always to true. This is one of 30+ viewer options that are described on the main documentation page.

<div class="Sirv" data-options="fullscreen.always:true">
<div data-src="https://demo.sirv.com/boot.spin"></div>
</div>

Instant fullscreen:

To set different settings for mobile devices, use one of three ways to apply options. The examples below change the spin hint message to “Tap then drag”.

Use a script to apply the settings to all instances on a page:

<script>
var SirvMobileOptions = {
spin: {
hint: {
message: {
text: 'Tap then drag'
}
}
}
};
</script>

Alternatively, apply inline settings to Sirv Media Viewer:

<div class="Sirv" data-mobile-options="spin.hint.message.text: Tap then drag"></div>

Or apply inline settings to a specific item inside the viewer:

<div class="Sirv">
<div data-src="https://demo.sirv.com/example.spin" data-mobile-options="hint.message.text: Tap then drag"></div>
</div>

List of API functions:

{
isInitialized: function () {},
isReady: function () {},
play: function (duration, effect) {},
pause: function () {},
rotate: function (x, y) {},
rotateX: function (frames) {},
rotateY: function (frames) {},
jump: function (rows) {},
jumpRows: function (frame) {},
jumpCols: function (frame) {},
zoomIn: function () {},
zoomOut: function () {},
isZoomed: function () {},
currentFrame: function () {},
getOptions: function () {}
}

The background color and opacity of thumbnail overlays can be controlled with CSS. The following CSS will apply a mid-grey color, with 56% opacity:

<style>
.smv-thumbnails .smv-selector[data-type="spin"]:before {
background-color: rgba(128, 128, 128, 0.56);
}
</style>

The 360 spin thumbnail can use any SVG or PNG image of your own design. Sirv provides a range of predesigned icons to choose from:

Those icons are available in black or white, ordered from 1 to 12 e.g.

Alternatively, you could design your own square SVG (or PNG) icon and apply it with CSS, like so:

<style>
.smv-thumbnails .smv-selector[data-type="spin"]:before {
background-image: url(https://youraccount.sirv.com/path/to/your/spin-icon.svg);
}
</style>

If you have a mixture of 360 (left/right motion) and 3D spins (left/right & up/down motion), you can show different thumbnails for different spins. Three icon types are possible, with CSS:

<style>
/* single-row spin */
.smv-thumbnails .smv-selector[data-type="spin"].spin-x:before {
background-image: url(https://youraccount.sirv.com/path/to/normal-spin-icon.svg);
}
/* single-column spin */
.smv-thumbnails .smv-selector[data-type="spin"].spin-y:before {
background-image: url(https://youraccount.sirv.com/path/to/vertical-spin-icon.svg);
}
/* multidimensional spin */
.smv-thumbnails .smv-selector[data-type="spin"].spin-xy:before {
background-image: url(https://youraccount.sirv.com/path/to/3D-spin-icon.svg);
}
</style>

Use CSS to customize the spin hint to perfectly fit your website design. Change the hint position; background colour; border style; text font size & colour, like so:

<style>
/* spin hint position */
.sirv-hint {
top: auto;
bottom: 0;
}
/* spin hint text and box colour */
.sirv-hint-message {
background-color: rgba(255, 255, 255, .8);
border: 3px solid #de0ced;
color: #de0ced;
font-size: 20px;
}
</style>

Customized spin hint:

It is possible to display a placeholder image until a spin has initialized. By default, if a spin is set to initialize on click, the first image of the spin will be shown.

It’s possible to choose any image that you wish, with some HTML and CSS.

Example:

<div class="Sirv" data-src="https://demo.sirv.com/example.spin">
<img class="cover-image" src="https://demo.sirv.com/example.jpg?w=400">
</div>
<style>
.Sirv {
position: relative;
}
.Sirv .cover-image {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
pointer-events: none;
cursor: pointer;
}
</style>

In case you cannot add a 360 spin to your page using a <div>, you can try using an <iframe> instead.

There are some notable disadvantages of iframes: the spin will stop rotating if the user drags beyond the edge of the iframe; the browser may not permit fullscreen and; scrollbars might appear beside the spin.

Otherwise, iframes can be an effective workaround when divs are not possible.

Embed an iframe like so (where 400 is the px height):

<iframe src="https://demo.sirv.com/drill/drill.spin" max-height="400" frameborder="0" allowfullscreen></iframe>

To optimize the speed of loading, the width of spin images are rounded up to the nearest 100px.

For example, if the viewport is 376px wide, a 400px width image will be served by Sirv (and scaled to 376px in the browser).

Rounding helps achieve a high CDN hit ratio, so that your spins load as quickly as possible while avoiding excessively large images. The same is true of image zooms.

Back to top