如何检测时,CSS动画,并开始使用JavaScript结束? [英] How do you detect when CSS animations start and end with JavaScript?
问题描述
我是用动画的JavaScript元素。我发现它简单用CSS3做。
I was used to animating elements with JavaScript. I found it simpler to do it with CSS3.
使用JavaScript你怎么能当一个CSS动画已经开始发现,当它已经结束?有没有在所有的什么办法?
Using JavaScript how can you detect when a CSS animation has started and when it has ended? Is there any way at all?
推荐答案
绑定相应的事件的元素,例如
Bind the appropriate events to the element, e.g.
el.addEventListener("animationstart", function() {}, false);
el.addEventListener("animationend", function() {}, false);
el.addEventListener("animationiteration", function() {}, false);
<一个href=\"https://developer.mozilla.org/en-US/docs/CSS/Tutorials/Using_CSS_animations#Using_animation_events\" rel=\"nofollow\">https://developer.mozilla.org/en-US/docs/CSS/Tutorials/Using_CSS_animations#Using_animation_events
请注意:您可能需要添加相应的prefixed事件为好,例如 webkitAnimationEnd
Note: You may need to add the appropriate prefixed-events as well, e.g. webkitAnimationEnd
这篇关于如何检测时,CSS动画,并开始使用JavaScript结束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!