Coder Social home page Coder Social logo

rodgath / judo-spin Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 17.28 MB

360° degrees image spinner using JavaScript.

Home Page: https://rodgath.github.io/judo-spin

License: MIT License

JavaScript 100.00%
360-image-slider 360-view image-spin 360-degree-image image-rotation

judo-spin's Introduction

Judo Spin

360° degrees image spinner and rotation built with vanilla JavaScript.


Table of Contents

Installation

[A] Download

[B] Package

  • Install with yarn: yarn add judo-spin

  • Install with npm: npm install judo-spin

  • NPM

[C] Get a local working copy of the development repository (Optional)
git clone https://github.com/Rodgath/judo-spin.git

Implementation

There are several methods you can use to add Judo Spin into your project.

Method 1

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>

Enqueue the judoSpin script at the bottom of your markup

  • 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>

Method 2

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>

Call the judoSpin() function with two arguments.

...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 });
});

Enqueue the judoSpin script at the bottom of your markup

  • 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>

Method 3

Using JSON object of images

...[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" }
      ]
    });
});

Options

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.

License

judoSpin is an open-source project released under the MIT license.


Crafted by Rodgath

judo-spin's People

Contributors

rodgath avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

bengoodson

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.