I've been having a few issues with two aspects of scrollable and autoscroll, I'm trying to get the autoscroll working on page load - but it's impossible to use the API to stop the autoscroll for the first item.
First case (autoplay enabled)
In this case it's impossible to stop the scroller for the first item only in the scrollable. The autoplay code in scrollable.autoscroll uses setTimeout, so until the first item has moved off you can't use .stop().
Second case (autoplay disabled, use .play() to start)
The scrollable immediately moves and then starts with the delay before the next move. In this case .stop() works properly. Is the initial move working as intended? Possibly, although in my opinion the functionality of autoplay should be identical to using .play(). If someone wants it to move immediately then they should use .move(x) then .play() afterwards.
Suggested changes:
This would make autoplay identical to play(), although for some users it might be a change in the expected functionality.
Thoughts?
First case (autoplay enabled)
var video_scroller = $(".scrollable").scrollable().autoscroll({api: true});
// In some other code:
video_scroller.stop();
In this case it's impossible to stop the scroller for the first item only in the scrollable. The autoplay code in scrollable.autoscroll uses setTimeout, so until the first item has moved off you can't use .stop().
Second case (autoplay disabled, use .play() to start)
var video_scroller = $(".scrollable").scrollable().autoscroll({autoplay: false, api: true});
video_scroller.play();
The scrollable immediately moves and then starts with the delay before the next move. In this case .stop() works properly. Is the initial move working as intended? Possibly, although in my opinion the functionality of autoplay should be identical to using .play(). If someone wants it to move immediately then they should use .move(x) then .play() afterwards.
Suggested changes:
api.play = function() {
// do not start additional timer if already exists
if (timer) { return; }
stopped = false;
// construct new timer
timer = setInterval(function() {
api.move(opts.steps);
}, opts.interval);
// Remove this
//api.move(opts.steps);
};
// and...
if (opts.autoplay) {
api.play();
// Remove this
//setTimeout(api.play, opts.interval);
}
This would make autoplay identical to play(), although for some users it might be a change in the expected functionality.
Thoughts?
