I have two functions, tick and tock. They cause 4 numbers to spin one direction then the other. Each number can ease at a different rate.
I can call both functions but I cannot get the second (tock) to wait until all the numbers have finished moving in the first (tick).
I have looked at other similar questions where a callback is used but I cannot seem to implement this with my example. I either end up with the second function proceeding before the first is finished or as is the case with the code below, only the first function is used.
Thanks
$(document).ready(function(){
var complete = 0;
tick('', function(){tock();});
function tick(a){
$('#col1 img')
.delay('1000')
.animate({bottom:'-=80px'},5000,'easeInOutSine');
complete++;
$('#col2 img')
.delay('1000')
.animate({bottom:'+=720px'},1000,'easeInOutSine');
complete++;
$('#col3 img')
.delay('1000')
.animate({bottom:'+=560px'},500,'easeInOutSine');
complete++;
$('#col4 img')
.delay('1000')
.animate({bottom:'-=240px'},2000,'easeInOutSine');
complete++;
}
function tock(){
$('#col1 img')
.delay('1000')
.animate({bottom:'+=80px'},2000,'easeInOutSine');
$('#col2 img')
.delay('1000')
.animate({bottom:'-=720px'},2000,'easeInOutSine');
$('#col3 img')
.delay('1000')
.animate({bottom:'-=560px'},2000,'easeInOutSine');
$('#col4 img')
.delay('1000')
.animate({bottom:'+=240px'},2000,'easeInOutSine');
}
});