开发者

jQuery cycle plugin

how can I set multiple timeout?

pls help me...

timeout:'1000, 2000, 3000' th开发者_开发问答is is not working.


Instead of using the timeout property, you should use timeoutFn and define there a function that returns the number of milliseconds to wait for the next slide.

For example if you have only 3 slides and you want those 3 timeouts you used (1000, 2000, 3000), then I assume that after the last timeout you want use the first timeout again (each picture have time to stay on screen). So in that case the code would simply be:

$('#s1').cycle({
    timeoutFn: function (curr, next, opts, isForward) {
        return (opts.currSlide + 1) * 1000;
    }
});

On the other hand, if you want to set more than 3 slides, then you can use your own properties (like an array and a counter) and use them inside the function to calculate the corresponding timeout:

$('#s1').cycle({
    timeoutFn: function(currElement, nextElement, opts, isForward) {
        opts.myTimeoutCount = (opts.myTimeoutCount + 1) % opts.myTimeouts.length;
        return opts.myTimeouts[opts.myTimeoutCount];
    },
    myTimeouts: [1000, 2000, 3000],
    myTimeoutCount: 0
});

And at last, if don't want to show any other slide after the last timeout then you should simply use the autostop & autostopCount properties:

$('#s1').cycle({
    autostop: true,
    autostopCount: 3,
    timeoutFn: function (curr, next, opts, isForward) {
        return (opts.currSlide + 1) * 1000;
    }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜