views:

68

answers:

2

I have three rotators on the front page and I'd like them to start 1 second after each other.

$(document).ready(function(){
 $('#rot_top').cycle({  
  speed: 500,
  timeout: 2000
 });
 $('#rot_mid').cycle({  
  speed: 500,
  timeout: 2000
 });
 $('#rot_btm').cycle({  
  speed: 500,
  timeout: 2000
 });
});

after the initial start - they should proceed according to their regular timeout.

Thank you so much for your help in advance.

A: 

setTimeout is pretty useful for this, give this a try:

$(document).ready(function(){ 

  startCycle = function({
    $('#rot_top').cycle({speed: 500, timeout: 2000 }); 
    $('#rot_mid').cycle({speed: 500, timeout: 2000 }); 
    $('#rot_btm').cycle({speed: 500, timeout: 2000 }); 
  })

  setTimeout(startCycle();, 1000)
});
Joseph Silvashy
I think this would cause all three rotators to start at the same time.
czarchaic
+1  A: 

It looks like you're using the jQuery Cycle plugin? If so, there's a delay option which delays only the first change:

$(document).ready(function(){
    $('#rot_top').cycle({           
        speed: 500,
        timeout: 2000
    });
    $('#rot_mid').cycle({           
        speed: 500,
        timeout: 2000,
        delay: 1000,
    });
    $('#rot_btm').cycle({           
        speed: 500,
        timeout: 2000
        delay: 2000,
    });
});

This will start the first cycle immediately, the second cycle a second later, and the third cycle a second after that.

Ben Blank