Is there a way to jump a jQuery animation forward / backward in time?
For example, if I have set an animation on an element to take 10 seconds, can I jump to '5 seconds' into that animation? Preferably, this could be set with a percentage.
Is there a way to jump a jQuery animation forward / backward in time?
For example, if I have set an animation on an element to take 10 seconds, can I jump to '5 seconds' into that animation? Preferably, this could be set with a percentage.
you could try to set up a queue in your animation OR
if you could provide an example surely you could receive a good hint ;)
You can stop the current animation, set the state of the animated object to halfway between its initial state and final state and then start a new animation to the original final state, but set for half the time.
That will jump to the halfway position of the animation and then continue going from there.
Here's a working example: http://jsfiddle.net/jfriend00/FjqKW/.
This should have everything you want but the percentage functionality:
Demo: http://jsfiddle.net/SO_AMK/MHV5k/
jQuery: