Git Product home page Git Product logo

simpleslider's Introduction

SimpleSlider

version: 0.5.0

Build Status

http://ruyadorno.github.com/SimpleSlider

A simple javascript slider without any dependencies on third-party libraries.

About

The main goal of the project is to provide a flexible yet simple solution for the common slider/carousel/gallery functionality. It is important to note that the script does not want to take care of any styling but the minimal in order to have a functional slider. It is all up to the front-end developer to configure its css in a proper way. To help with that, many sample uses are provided in the example folder.

This package only supports the Javascript basic usage. If you are using modern frameworks like AngularJS or Polymer please take your time to check the following SimpleSlider element implementations:

Features

  • Support to UMD: AMD, CommonJS and global definition
  • Uses requireAnimationFrame and its polyfills for animation
  • Supports Page visibility API to pause/resume autoPlay when user navigates away from the page
  • Accept ease functions to customize the transition animation
  • Lots of examples, just check the example folder included on this repo
  • Animates any numerical css property
  • Support to ie9 and partially ie8 (only position animations, no fading out animations for old ies)

Usage

Just import the script on html and create a new slider instance. You always have to define width and height values to your container element.

Basically the slider takes the element that handles the gallery as the first parameter, this will be usually a div or ul containing the elements to be transitioned.

<div id="myslider" style="width:612px; height:612px">
  <img src="http://placekitten.com/g/612/612"/>
  <img src="http://placekitten.com/g/612/613"/>
</div>
<script src="simpleslider.min.js"></script>
<script>
  var slider = new SimpleSlider( document.getElementById('myslider') );
</script>

In this previous example we did not specified any addition option, so the slider will use its default left-to-right sliding animation.

Options

Options can be set to help you customize your slider, just set a second parameter specifying values such as duration of the transition, css property to be animated, etc.

<div id="myslider" style="width:612px; height:612px">
  <img src="http://placekitten.com/g/612/612"/>
  <img src="http://placekitten.com/g/612/613"/>
</div>
<script src="simpleslider.min.js"></script>
<script>
  var slider = new SimpleSlider( document.getElementById('myslider'), {
    autoPlay:false,
    transitionTime:1,
    transitionDelay:3.5
  } );
</script>

Available Options

Here is the list of available values to use on the constructor and customize your animation:

  • autoPlay: Value determining if the slide transition should happen automatically
  • transitionProperty: Determines the css property to be animated
  • transitionDuration: Value setting the duration of animation transition
  • transitionDelay: Value determining the wait between each animation when you use autoPlay:true
  • startValue: <String/Number> Initial value of slide elements when starting a transition animation
  • visibleValue: <String/Number> The value a slide element should have when it is displayed
  • endValue: <String/Number> The value a slide will move to during a transition animation
  • ease: An ease function, you can use any of these
  • onChange: A callback function to be invoked each time a slide changes

Default values

{
  autoPlay: true,
  transitionProperty: 'left',
  transitionDuration: 0.5,
  transitionDelay: 3,
  startValue: -elem.width,
  visibleValue: 0,
  endValue: elem.width,
  ease: SimpleSlider.defaultEase,
  onChange: null
}

More examples

There are many more usage samples in the examples folder, including all the available options for the slider.

More documentation about the methods and properties of a can be found at the SimpleSlider official documentation.

License

Released under the MIT License.

simpleslider's People

Contributors

cyberglot avatar joonxz avatar mozmorris avatar ruyadorno avatar

Watchers

 avatar

Forkers

frankcollins3

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.