开发者

JQuery Cycle Synchronization

I have defined two slideshow by JQuery cycle below:

    $('#slideShow').cycle({
        fx: 'fade',
        timeout: 3000,
        speed: 2000,
        random: 1
    });

    $('#slideText').cycle({
        fx: 'blindZ',
        timeout: 3000,
        speed: 2000,
        random: 1
    });

I have validated manually and they are in sync. Actually is that just luck or I need to define something like below to ensure they are in sync:

  1. set timeout parameter as 0 in cycle to ensure it will not auto update.
  2. use setInterval function with same interval to trigger each cycle.
开发者_如何学C

Thanks for your kind assistance.


As long as you start your two slideshows one after another, it should be ok. Since they have the same timeouts and are started together, they should stay in sync.

Otherwise you could do something like this ;

$('#slideShow').cycle({
    fx: 'fade',
    timeout: 3000,
    speed: 2000,
    random: 1,
    after: function(currSlideElement, nextSlideElement, options, forwardFlag) {
          $('#slideText').cycle('next');
    }
});

$('#slideText').cycle({
    fx: 'blindZ',
    timeout: 0,
    speed: 2000,
    random: 1
});

The second slideshow is deactivated, and the first one sends a 'next' command after each change.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜