GithubHelp home page GithubHelp logo

liteslider's Introduction

liteSlider

liteSlider is a simple, fast, lightweight HTML content slider with an emphasis on quick user response and fast animation. Slides an be timed to move automatically or advanced manually by the user, or both! They can transition in the four cardinal directions as well as cross-fade. liteSlider is written in pure JavaScript; no need for a heavy supporting framework.

Examples can be found here.

How to use

liteSlider uses a target <UL> element with each <LI> child representing a frame. Simply instantiate a new instance of the liteSlider object with the ID of the <UL> element along with an object containing the settings for the slider:

var newslider = new liteSlider('ls-slider',
  {
    autostart:false,
    nextDirection:'up'
  });

The liteSlider object also has methods for manually moving to the next and previous frames, which can be bound to DOM events like mouse clicks:

document.getElementById('nextslide').addEventListener('click',function() {
  newslider.nextSlide();
},false);

Legacy Internet Explorer support

liteSlider comes in two versions: one for modern browsers (IE10+, Chrome, Firefox) and one for legacy IE (8 and 9). The modern version makes use of the requestAnimationFrame functionality to make smoother animations with less CPU cost; the legacy version uses the setInterval method. Needless to say if you don't need older IE support... use the modern one!

Methods

nextSlide() Moves to the next slide

prevSlide() Returns to the previous slide

rebuild() Rebuilds the slides from the LI children. This should be used on a dynamic page where LI elements are added or removed.

resetTimer() Resets the timer for automatic slide advances. This is useful if a slider moves automatically but also has user input to manually move slides; resetting the timer will prevent the slide from moving automatically soon after the user manually moves a slide.

slideTo(index) Moves to the specified slide by its index.

start() Start the automatic slide advance.

stop() Stop the automatic slide advance.

Settings

autostart (boolean, default: true) This option will enable automatic slide advance as soon as the slides are built and ready.

displayTime (number, default: 5000) The amount of time (in milliseconds) that a slide will show before automatically transitioning, if automatic advance is enabled.

nextDirection (string, default: 'left') The transition method for moving to the next slide. Valid options are up, down, left, right and fade.

overwrite (boolean, default: false) If overwrite is false, the old slide is moved out as the new slide transitions in. If overwrite is true, the old slide doesn't move, causing the new slide to 'overwrite' the old one as it moves in.

prevDirection (string, default: 'right') The transition method for moving to the previous slide. Valid options are up, down, left, right and fade.

transitionTime (number, default: 900) The speed (in milliseconds) for a slide to transition.

liteslider's People

Contributors

drojaazu avatar

Watchers

 avatar

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.