jump forward in jQuery animation?

匿名 (未验证) 提交于 2019-12-03 08:50:26

问题:

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.

回答1:

http://api.jquery.com/queue/

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 ;)



回答2:

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/.



回答3:

This should have everything you want but the percentage functionality:

Demo: http://jsfiddle.net/SO_AMK/MHV5k/

jQuery:



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!