开发者

Is there a way to rollback an animation using only jQuery?

开发者 https://www.devze.com 2023-04-04 18:04 出处:网络
Imagine I have the following animations: $(\"#myObject\").animate({ /* animation 1 */ }).animate({ /* animation 2 */

Imagine I have the following animations:

$("#myObject").animate({
    /* animation 1 */
}).animate({
    /* animation 2 */
}).animate({
    /* animation 3 */
});

I was wondering if is there a way to animate #myObject back on a reverse order w开发者_StackOverflow社区ith reverse attributes without writing it all over again.

I was thinking about making a css class and toggle it, but it won't have the animation steps. Also, css3 animations is not an option for this project.

Is it possible?


So, I thought this was a fun question, and I wrote this: http://jsfiddle.net/bstakes/hzFTg/#base

Its a very naive implementation, but it does what you are asking. So, yes there is a way to do it, but not out of the box.

0

精彩评论

暂无评论...
验证码 换一张
取 消