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);
};
精彩评论