Git Product home page Git Product logo

whirl's Introduction

Whirl

forthebadge

An ES6 script that lets you scrub through a dropped in list of sequential images. This works particularly well for 360° rotating product images.

Getting Started

Whirl is written in ES6, so before running in a browser you'll need to pipe it through your favourite transpiler. If you don't want to go through that hassle, you can get the transpiled version in gh-pages.

After doing so, create an element that will be used as a drop-zone and reference the script just before the end of the body tag:

    <div id="zone"></div>

    <script src="Whirl.js"></script>
  </body>
</html>

Once the script is referenced, you can create a new instance and pass in the drop-zone element as the only parameter:

var zone = document.getElementById('zone');

var whirl = new Whirl(zone);

Options

Whirl automatically inserts three nodes into the DOM: div.whirl-splash & div.whirl-loading into the zone and canvas into the body. You have the option to create custom splash and loading elements by manually putting them inside the zone element:

<div id="zone">
  <div class="whirl-loading">A custom loading element</div>
  <div class="whirl-splash">A custom splash element</div>
</div>

Demo

To see a working demo, head over to jaden.io/whirl and drop in a list of sequential images.

whirl's People

Contributors

baptistebriel avatar jadnco avatar nilshoenson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jameswquinn

whirl's Issues

Add custom options

A custom options object should be able to be passed in when the object is instantiated. This would include things like:

  • Canvas width & height
  • Image width & height
  • Size threshold
  • etc.

Drag overflow

Right now, drags are being listened for on the zone node. If the cursor goes outside of it's bounds, the events are no longer called.

Going over bounds to the left should reset current to the end and set to the start when going over the right bound. This would give it a seamless loop. Drags would need to be called on the document.

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.