[英].animate return back to original state
Currently I'm using this code for animating back to original state 目前,我正在使用此代码将动画设置回原始状态
this.stop().animate(animateVal1, animateMs).delay(duration).animate(animateVal2, animateMs, function() {
this.removeAttribute('style');
});
Is that possible to return back original state without fading to second color animateVal2
? 是否有可能返回到原始状态而不会退色到第二种颜色animateVal2
? (I mean after animating to first color I want to remove style
attribute with animation.) (我的意思是在动画到第一种颜色之后,我想用动画删除style
属性。)
This is what I understood from your question: 这是我从您的问题中了解的:
You have a element X
, which is in state A
(due to some applied classes from CSS Rules). 您有一个元素X
,它处于状态A
(由于CSS规则中的某些应用类)。
You want to animate it to state B
, using jquery.animate()
, but you want to return it to the original state A
. 您想使用jquery.animate()
将其设置为状态B
动画,但您希望将其返回到原始状态A
But you do not have a Javascript object containing all the properties of A
at the time the animate function can execute. 但是,在执行动画功能时,您没有包含A
所有属性的Javascript对象。
For this, I recommend you use jQuery UI's switchClass function. 为此,我建议您使用jQuery UI的switchClass函数。
this.stop().switchClass('classB', animateMs).delay(duration).switchClass('originalClass', animateMs);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.