MooSlider is a lightweight, easy-to-use content (e.g. images, text, ...) scroller using the mootools framework.
In your HTML source:
<div id="MooSlider_1"> <div class="MooSlider_Item"> Content #1 </div> <div class="MooSlider_Item"> Content #2 </div> <div class="MooSlider_Item"> Content #2 </div> ... <div class="MooSlider_Item"> Content #N </div> </div>
In your Javascript source:
window.addEvent('domready', function() { // ... your other code here var yourmooslider = new MooSlider($$('#MooSlider_1 .MooSlider_Item'), { mode: 'alpha' }); yourmooslider.play(); });
You can see that the MooSlider class is instantiated like any other MooTools class, using the generic
new MooSlider(Array_of_element_to_slide, options)
To use the auto-slide thing, now use the
.play(initial_delay)
method, where initial_delay specifies the time in milliseconds to wait before the first sliding (optional, defaults to 0).
For possible options, see next section.
You can pass several options to the MooSlider constructor. Every of the options has a default value, hence is optional and can be left out.
mode (string or array): Specifies the animation type. One or an array of:
modes (array): (Only applies if mode is set to random) An array of all modes from which one shall be chosen randomly every transition (default: all available modes)
interval (int): Time to wait between slidings (in milliseconds, only applies if you use the .play() auto-slide function)
fxOptions: Options passed to Fx.Tween used for transitions (defaults to {duration: 500})
sizes (object): A hashtable containing the keys w (Slider container width) and h (Slider container height), both of type int. (default: empty, so height and width are gained from the first item in the slide elements array)
buttons (object): A hashtable containing one or more of the keys next, previous and playpause, all of type Element. To each of the given elements, a click event is added. Then if one clicks a button, the according action ("slide to next element", "slide one element back", "play/pause the auto-slide") is executed.
window.addEvent('domready', function() { var slider = new MooSlider($$('#MooSlider_1 .MooSlider_Item'), { mode: 'right', interval: 3000, sizes: {w: 300, h: 300}, buttons: { next: $('MooSlider_1_Button_Next'), previous: $('MooSlider_1_Button_Previous'), playpause: $('MooSlider_1_Button_PlayPause') } }); slider.play(2000); });
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus