开发者

How to stop AnythingSlider on the final slide?

How can I ma开发者_StackOverflow中文版ke the slider stop playing once it reaches the final slide? It's this slider here.


There is no native support for stopping the auto play on the last slide. I don't have the time just now to make an example but it looks like you can ammend the js file to stop the autoplay after the last slide.

In line number 136 of the js file, replace the existing function with the following:

base.goForward = function(autoplay){
if(autoplay !== true) autoplay = false;

if(autoplay && base.currentPage == base.$items.length()-1) {
base.startStop(false); // stops auto play
return;
}
base.gotoPage(base.currentPage + 1, autoplay);
};

I can't test this just now but it shouldn't be far away from your requirement.


Brian's answer was almost spot on. The only change needed was to base.$items.length()-1

The correct code, for anyone who might want to use it, is:

base.goForward = function(autoplay){
    if(autoplay !== true) autoplay = false;
    if(autoplay && base.currentPage == base.pages) {
        base.startStop(false); // stops auto play
        return;
    }
    base.gotoPage(base.currentPage + 1, autoplay);
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜