Flickable is a simple Javascript library for creating iOS-style flickable galleries on touch-enabled devices.
A demo can be viewed at flickable.aurlien.net.
The library provides a single function, Flickable
, which takes two arguments:
- A selector for the flickables
- A settings object
The matched element(s) should contain a second element, which should contain the actual slides. The slides must be of the exact same width, and should be of the same height (for aestethic reasons).
The file flickable.css
contains the recommended CSS rules for the flickable elements.
Simple usage:
<div class="flickable">
<ul>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ul>
</div>
<script type="text/javascript">
Flickable('.flickable', {
width: 320
});
</script>
width
: The width of each item, including margin, padding and border. Use 'screen' to auto-fit and resize with screen. Default:'screen'
offset
: Which item to start at. Default:0
enableMouseEvents
: Whether to enable mouse events (useful for testing). Default:false
showIndicators
: Whether to show indicators for which item is selected. Default:true
showButtons
: Whether to show next/previous-buttons for devices that support touch events. Default:false
nextButtonText
: Text for next-button. Default:'Next'
prevButtonText
: Text for previous-button. Default:'Previous'
indicatorClass
: The class name for the indicator wrapper element. Default:'flickableIndicator'
activeIndicatorClass
: The class name for the active indicator element. Default:'flickableIndicatorActive'
callback
: A function to be called each time the slide changes. The function will be passed the slide number (zero-indexed) as a parametertimeInterval
: gallery auto-rotation time in seconds. Default:0
.
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php