Navneet
Navneet

Reputation: 9848

Animate function call subtleties

I am trying to make a callback possible after an animation is complete.

pieceimg.animate({path:path}, {duration:2000*path.length,  //120
                               step:path.step,
                               easing:"linear",
                               complete:function() {
                                                     if (finalcallback)                
                                                         finalcallback(); 
                                                   }
                });

path is a simple javascript "class" which has some prototype functions defined correspondingly.

When does the complete call happen here? Is is at the end of every step (but then step is supposed to called too)?

I have some animation in the finalcallback() function. It gets triggered before this animation is complete. Need help!!

Thanks!

Upvotes: 1

Views: 83

Answers (1)

gnarf
gnarf

Reputation: 106392

You might be having problems because your animation isn't animating a css property.

Take a look at this example that I used in my presentation at the 2011 jQuery Conference in Boston.

Animate is pretty picky / tied into CSS properties so you need to set some fake property to 0, so that it detects it as "animatable".

In your example, only one "frame" of the animation ever plays because it doesn't detect the path property as something it can animate.

Upvotes: 1

Related Questions