360° degrees image spinner and rotation built with vanilla JavaScript.
[A] Download
- judo-spin.min.js - Minified
- judo-spin.js - Unminified
[B] Package
[C] Get a local working copy of the development repository (Optional)
git clone https://github.com/Rodgath/judo-spin.git
There are several methods you can use to add Judo Spin into your project.
Using data-judo-spin
attribute. View Demo
Your HTML code of upto 36 images
<div data-judo-spin='{ "currImage": "6" }'>
<img src="images/car/01.png" alt="Image 01">
<img src="images/car/02.png" alt="Image 02">
<!-- More Images Here -->
<img src="images/car/35.png" alt="Image 35">
<img src="images/car/36.png" alt="Image 36">
</div>
- Using local script file.
<script src="judo-spin.min.js"></script>
<!-- OR -->
<script src="./node_modules/judo-spin/dist/js/judo-spin.min.js"></script>
- Using CDN file. (Optional)
<script src="https://cdn.jsdelivr.net/npm/judo-spin@latest/dist/js/judo-spin.min.js"></script>
Initializing with judoSpin
function. View Demo
Your HTML code of upto 36 images
<div class="image-spin-box">
<img src="images/car/01.png" alt="Image 01">
<img src="images/car/02.png" alt="Image 02">
<!-- More Images Here -->
<img src="images/car/35.png" alt="Image 35">
<img src="images/car/36.png" alt="Image 36">
</div>
...1) The element 'class' or 'id' holding the images
...2) The 'options' object
document.addEventListener('DOMContentLoaded', function() {
judoSpin('.image-spin-box', { currImage: 1, enableDragHangle: true });
});
- Using local script file.
<script src="judo-spin.min.js"></script>
<!-- OR -->
<script src="./node_modules/judo-spin/dist/js/judo-spin.min.js"></script>
- Using CDN file. (Optional)
<script src="https://cdn.jsdelivr.net/npm/judo-spin@latest/dist/js/judo-spin.min.js"></script>
...[A] - Adding the JSON object inside the data-judo-spin
attribute. View Demo
<div data-judo-spin='{
"currImage": 13,
"images": [
{ "src": "images/car/01.png", "title": "Image 01" },
{ "src": "images/car/02.png", "title": "Image 02" },
// More Images Here
{ "src": "images/car/35.png", "title": "Image 35" },
{ "src": "images/car/36.png", "title": "Image 36" }
]
}'></div>
...[B] - Add the JSON object inside the judoSpin
function. View Demo
HTML code.
<div class="image-rotation-box image-spin-demo"></div>
JavaScript code
document.addEventListener('DOMContentLoaded', function() {
judoSpin('.image-rotation-box', {
currImage: 22,
images: [
{ "src": "images/car/01.png", "title": "Image 01" },
{ "src": "images/car/02.png", "title": "Image 02" },
// More Images Here
{ "src": "images/car/35.png", "title": "Image 35" },
{ "src": "images/car/36.png", "title": "Image 36" }
]
});
});
Name | Type | Default | Description |
---|---|---|---|
currImage |
number | 1 | The default image when judo spin loads. Range is 1 - 36. |
images |
array | object | - |
enableDragHandle |
boolean | false | Whether to show the drag handler scroller. |
judoSpin is an open-source project released under the MIT license.
Crafted by Rodgath