如何检测时,CSS动画,并开始使用JavaScript结束? [英] How do you detect when CSS animations start and end with JavaScript?

查看:178
本文介绍了如何检测时,CSS动画,并开始使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆