tags:

views:

99

answers:

2

The title explains the question, otherwise is there way to call a function when all the effects on a page are done running?

+2  A: 

You might be able to make use of .queue to get the functionality you are after. If the length of the queue was 0 you would know that all animations on the object are finished.

Documentation

Corey Downie
that is close, though I was hoping for a way to do this without changing the existing effects.
I haven't seen your code, but my understanding is that the queue gets populated for any object running an animation. I don't expect there would be big changes to your code in order to query the queue array.
Corey Downie
+3  A: 

You could nest your animations like this

$('#Div1').slideDown('fast', function(){
   $('#Div2').slideUp('fast');
});

And do them sequentially...

You could also do something like this:

var animations = 0;
checkAnimation(1);
$('#Div1').slideDown('fast', function(){
   checkAnimation(-1);
});

checkAnimation(count){
   animations += count;
   if(count == 0)
      //animations complete
   }
   else {
       //still animating
   }
}

Hope this helps.

Birk