我正在为一个元素应用CSS过渡。
当前的过渡只是继续进行。
执行。
target.style.transition = "color 10000ms ease";
target.style.color = "red";
在某些情况下,我希望达到这个转换的结束状态,而无需等待转换完成。
如果我尝试
target.style.transition = "color 0ms";
target.style.color = "red";
当前的过渡只是继续进行。
执行。
target.style.transition = "color 0ms";
target.style.color = "blue";
立即将其设置为“blue”,而
target.style.transition = "color 0ms";
target.style.color = "blue";
target.style.color = "red";
结果会继续过渡。(在Chrome和FF中尝试过)
有没有办法停止过渡?
#FE0000
,然后使用setTimeout(function(){/*在此处设置为适当的红色*/},0)
(对于您可能正在动画化的其他几个属性也适用)。或者您可以使用setInterval
或jQuery手动进行动画处理。 - Dave