#32: Carousel : Simple auto start method - Automatic sroll (Open)
Nov 26 2008 * 11:48
| Reported by: | Assigned to: | ||
|---|---|---|---|
| Priority: | Normal | Milestone: |
A very simple method to start scrolling Carousel automatically. The autoscroll effect will stop on any mouseover event on carousel.
You only have to set time interval between 2 scrolls in options (in seconds) : new UI.Carousel(“horizontal_carousel”,{autoStart:3});
Code change:
.......................
// Group: Options
options: {
},
.......................
// Property: autoScroll
// Time in second between to scrolling
autoStart : 0
.......................
/*
Method: autoStart
Scrolls carousel automatically until any mouseover event
*/
autoStart: function() {
var scrollInc = this.options.scrollInc;
if (scrollInc == "auto") scrollInc = Math.floor(this.nbVisible);
},
// Init
this.autoStop = false;
var dir = -1; // || 1
// Check timer initialization
if (this.options.autoStart <= 0 ) return;
// Stop executer on carousel mouseover
this.element.observe("mouseover", function() { this.autoStop = true; }.bind(this));
// Start Periodical scrolling
new PeriodicalExecuter(function(pe) {
}.bind(this), this.options.autoStart);
if (this.autoStop) {
pe.stop();
} else {
}
// Get Direction
if (this.currentLastPosition() == this.currentSize()) dir = 1;
else if (this.currentPosition() == 0) dir = -1;
// Scroll
this.scroll(dir * scrollInc * this.elementSize);Changelog:
Modified by – Nov 26 2008 * 11:59
- Attachment added carousel_autoStart.js [text/javascript]
ok sorry for last post…. My stupid cat !! (no kidding :D ) sent it before finished…
The code is in attachement file.
Just test with : new UI.Carousel(“horizontal_carousel”,{autoStart:3});
Modified by – Jul 08 2010 * 03:03
Thanks – just what I was looking for. Very useful.


RSS feeds