lanxyou / iSlider

Smooth mobile touch slider for Mobile WebApp, HTML5 App, Hybrid App

Home Page:http://be-fe.github.io/iSlider/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iSlider

iSlider English README

iSlider DEMO

iSlider 中文文档

iSlider 演示

iSlider animation

iSlider is a light-weight, high performance, dependency free, yet cross-platform plugin.

It can help handling most sliding effects, offering dozens of transition animation, and presenting various scenarios.

Currently, it features:

  • Outstanding performance, less memory required
  • Various animation effects, and capability of adding custom animations
  • Easy to configure, e.g. Auto-play, looping, vertical/horizontal sliding etc.
  • Ability to load features on demand
  • Numbers of configurable callbacks

Mobile demo

Demo http://be-fe.github.io/iSlider/index.html

Installation

You can either:

  • Download directly from Github
  • Run bower install iSlider if bower is used
  • Run npm install islider.js

Get started

The easiest way to get your hands dirty is to have a try the cases that we offer. Please refer to the folder demo/ for more information.

Creating a container

<div id="iSlider-wrapper"></div>

Preparing some data

var data = [
    {content: "imgs/1.jpg"},
    {content: "imgs/2.jpg"},
    {content: "imgs/3.jpg"}
];

Loading iSlider

<script src="iSlider.min.js"></script>

Initializing a iSlider

var islider = new iSlider(document.getElementById('iSlider-wrapper'), data);

you can also

var islider = new iSlider({
    dom : document.getElementById('iSlider-wrapper'),
    data : data
});
var islider = new iSlider(document.getElementById('iSlider-wrapper'), data, {
    dom : document.getElementById('iSlider-wrapper'),
    data : data
});

Options properties precedence over parameters

Extending iSlider

Animations

If you want more effects, you can load the animation effect extensions, set up the configuration when initializing iSlider and specify animationType.

<script src="iSlider.min.js"></script>
<script src="iSlider.animate.min.js"></script>
var islider = new iSlider({
    dom: document.getElementById("iSlider-wrapper"),
    data: list,
    isVertical: true,
    isLooping: false,
    isDebug: true,
    isAutoplay: false,
    animateType: 'rotate'
});

Extension

From 2.x, iSlider supports extension registration. You can now extend iSlide with your own features.

<script src="iSlider.min.js"></script>
<script src="iSlider.plugin.dot.min.js"></script>
var islider = new iSlider({
    dom: document.getElementById("iSlider-wrapper"),
    data: list,
    plugins: ['dot'],
});

You can surely pass in more customed params to the extension initialize method.

var islider = new iSlider({
    dom: document.getElementById("iSlider-wrapper"),
    data: list,
    plugins: [['dot', {background:'rgba(0,0,0,0)'}]],
});

That's it!

Customise your iSlider

From 2.x, iSlider no longer requires type to specify the data type. It can now detect wisely, so that you can easily use various types of data, e.g. images, HTML elements or fragments.

var data = [{
    'content' : './qrcode.png'  // picture
},{
    'content' : '<div><h1>Page1</h1><h2>This is page1</h2><p>page1 is pretty awsome</p><div>' // HTML
},{
    'content' : (function () { // element
            var dom = document.createElement('div');
            dom.innerHTML = 'Element';
            return dom;
        })()
},{
    'content' : (function () { // fragment
            var frag = document.createDocumentFragment();
            var dom = document.createElement('div');
            dom.innerHTML = 'Fragment';
            frag.appendChild(dom);
            return frag;
        })()
}];

To learn more advanced features, please refer to WIKI

Detailed explanation of the configuration options

Option Type Explanation
Required
dom {HTML Element} Container node
data {Array} data list:
[{ content:'{url|HTML string|element|fragment}', }, ...]
Options
type (obsolete) - -
duration {Number} Sets the duration of each scene during auto-play mode. Unit: millis.
animateType {String} Sets the animation type. Currently it could be one of `default`, `rotate`, `depth`, `flow`, `flip` and `card`
animateTime {Number} Duration of the animation. Unit: millis.
animateEasing {String} Animation easing function. Possible values are `linear`, `ease`, `ease-in`, `ease-out`, `ease-in-out` or customed `cubic-bezier`
isDebug {Boolean} If true, more logs will be output. Default: false (disabled)
isLooping {Boolean} Turns on/off the loop mode. Default: false (turned off)
isAutoplay {Boolean} Turns on/off the auto sliding mode. Default: false (turned off)
isVertical {Boolean} Sets vertical/horizontal sliding. Default: false (horizontal)
isOverspread {Boolean} Makes the image overspread the whole viewport (as CSS3 `background-size: cover`), if the scene mode is image. Default: false (disabled)
isTouchable {Boolean} Enable/disable touch events. Default: true (enabled)
initIndex {Number} Specifies an index as the default home scene
fixPage {Boolean} Whether to disable native scrolling and rebound effect. Default: true (enabled)
fillSeam {Boolean} Fill the seam between scenes. Default: false (disabled)
plugins {Array} Enables plugins. It could be a simply list of plugin names:
['dot', 'button', 'zoompic', ...]

Or, it could be a more complex list which can also contain init params for plugins:
[..., ['zoompic', {zoomFactor: 2}], ...]
Events
initialize {Function} Gets called on iSlider start initialization (after setting, before render)
initialized {Function} Gets called on iSlider initialized (after render)
onslide {Function} Gets called on sliding
onslidestart {Function} Gets called when the sliding event starts
onslideend {Function} Gets called when the sliding event ends
onslidechange {Function} Gets called when the scene gets changed
onslidechanged {Function} Gets called post scene change (when the transition animation ends)
onsliderestore {Function} Gets called if scene restores
onsliderestored {Function} Gets called post scene restore (when the rollback animation ends)

More of iSlider

Methods Params Explanation
Static methods
extend [{Object} The original Object (Optional)]
{Object} The new Object
When the length of params is 1, the param object will be extended to iSlider.prototype
When the length is 2, use the second object as the param object, and extend all it's methods to the first object.
regPlugin {String} Plugin name
{Function} Init method for a plugin
register plugin
Instance methods
slideTo {Number} index of a scene
[{Object} one-off configuration (optional)]
Slide to the N scene. Using the one-off configuration param, the transition effect for this particular slide can be specified. i.e. animateTime, animateType
slideNext [{Object} one-off configuration (optional)] Slide to the next scene. The one-off configuration can be used to specify the transition effect. i.e. animateTime, animateType
slidePrev [{Object} one-off configuration (optional)] Slide to the previous scene. The one-off configration can be used to specify the transition effect. i.e. animateTime, animateType
delegate {String} event name
{String} selector (same syntax as querySelectorAll)
{Function} event hanlder method
Bind event handler to a node container
bind Alias of delegate
unDelegate {String} event name
{String} selector (same syntax as querySelectorAll)
{Function} event hanlder method
unBind event handler
unbind Alias of unDelegate
on {String} event name
{Function} event handler method
Register event handler for iSlider events
  • initialize
  • initialized
  • slide
  • slideStart
  • slideEnd
  • slideChange
  • slideChanged
  • slideRestore
  • slideRestored
  • reloadData
  • destroy
off {String} event name
{Function} event handler method
Remove an event handler from the registered handlers for a specified event
fire {String} event name Trigger an event manually
play Start auto-play (auto-play mode must be specified)
pause Stop auto-play (auto-play mode must be specified)
extend Equivalent to iSlider.extend
regPlugin Equivalent to iSlider.regPlugin. Once registered, the plugin will be added to the active plugin list, and be initialized automatically.
loadData {Array} list of data Loads a list of data
hold Prevents the scene from any gesture
unhold Resumes and allows gesture on the current scene
lock Locks the current scene, disables `slideTo`, `slideNext` and `slidePrev` and also disable all gestures.
unlock Unlocks the scene
destroy Destroys the current iSlider instance, and frees memory
reset Resets the current iSlider instance

Contact us

Any feedback is most welcome if you have any question regarding iSlider or any bug is found: Commit a feedback

License (MIT)

Copyright (c) 2014 BE-FE

MIT

About

Smooth mobile touch slider for Mobile WebApp, HTML5 App, Hybrid App

http://be-fe.github.io/iSlider/

License:MIT License


Languages

Language:JavaScript 62.1%Language:HTML 31.9%Language:CSS 6.0%