私は問題なくjquery.cycle()を使用しています>
ただし、上司は、スライドを2回ループしてから、最初のスライドで停止することを望んでいます。
自動停止で1回ループできることがわかります。しかし、スライドショーが2回ループするように指定するにはどうすればよいでしょうか。
できますか?
使用autostopCount
: http://jquery.malsup.com/cycle/options.html
autostop:0, // true to end slideshow after X transitions (where X == slide count)
autostopCount: 0, // number of transitions (optionally used with autostop to define X)
別のオプション、それが私が思うように機能しない場合:
$(document).ready(function(){
var index = 1;
var interval = setInterval(function(){
$('#slideshow').cycle('next');
index++;
if(index == cycleLength*2) {
clearInterval(interval);
}
}, 1000);
});
自分で用意する必要がありcycleLength
ます。
以前の回答を説明するために、X がhttp://jsfiddle.net/lucuma/LKUyg/に移行した後に最初のスライドで停止する実際のコード:
var numberReptitions = 2;
$('#slideshow').cycle(
{
autostop:1, // true to end slideshow after X transitions (where X == slide count)
autostopCount: ($('#slideshow').children().length*numberReptitions)+1
});
リトルビッグボットに加えて、
目的のロジックに基づいて「after」イベントをチェックすることで、サイクルを一時停止できます
var numberOfImages = 3;var counter=0;
after: function(currSlideElement, nextSlideElement, options, forwardFlag) {
counter++;
if(counter > numberOfImages*2)
$('#slideshow').cycle('pause');
}