Because I need to call a function if the animation element. Not onComplete animation.
Since $(element).on(":animated", function(){ ... }); doesn't seem to work, the only way I can see is to very simply execute the function that you want to call when the animation is executed:
$(selector).animate( . . . ); functionToCall();
Another solution is to create your own library that handles the start of the animation, and also processes calls to the necessary functions after it starts the animation in the simple way described above.
So just psuedocode:
var animation = new MyAnimationLibrary(function() { $(selector).animate( ... ) }); animation.onStart.push(function() { alert('animation starts'); });
Then just make the above function call in the animation.onStart array and start the animation.
David sherret
source share