ThreeSixty.js

Turn image sprite into 360 degree image.

View on Codepen - http://codepen.io/mladenilic/full/zKOpmg/
Install
ThreeSixty is available as an ES6 module via NPM package
npm i @mladenilic/threesixty.js
Then you can import it with
import ThreeSixty from '@mladenilic/threesixty.js';
Or, you can also use it via a CDN
<script src="https://cdn.jsdelivr.net/npm/@mladenilic/threesixty.js/dist/threesixty.js"></script>
Dependencies
No dependencies! Written in plain javascript.
Example
const threesixty = new ThreeSixty(document.getElementById('threesixty'), {
image: 'images/example.jpg',
count: 19,
perRow: 4,
prev: document.getElementById('prev'),
next: document.getElementById('next')
});
threesixty.play();
Options
{
image: 'images/example.jpg',
count: 30,
perRow: 5,
width: 300,
height: 300,
prev: document.getElementById('prev'),
next: document.getElementById('next'),
keys: true,
draggable: true,
swipeable: true,
dragTolerance: 10,
swipeTolerance: 10,
swipeTarget: document.getElementById('wrapper'),
speed: 100,
inverted: false
}
Array of images
As an alternative to sprite image, ThreeSixty also supports using array of images:
new ThreeSixty(document.getElementById('threesixty'), {
image: [
'images/example-1.jpeg',
'images/example-2.jpeg',
'images/example-3.jpeg',
...
],
...
})
In this case options count and perRow are ignored.
Methods
Single frame rotation:
threesixty.next();
threesixty.prev();
Focus n-th frame:
threesixty.goto(index);
threesixty.goto(0);
threesixty.goto(1);
threesixty.goto(-1);
Image rotation:
threesixty.play();
threesixty.play(true);
threesixty.play(false, 2);
threesixty.stop();
threesixty.toggle();
Clean up registered events:
threesixty.destroy();
Contributions
All contributions are welcome. To get started, clone repo and npm start
Licence
Licensed under the MIT license.
评论