views:

182

answers:

2

how can I set multiple timeout?
pls help me...

timeout:'1000, 2000, 3000' this is not working.

+1  A: 

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;
    }
});
Protron
A: 

Thank you Protron!

--Rizu

Rizu
You are welcome. And, by the way, you can mark my answer as "accepted answer" if that solved your problem.
Protron