在完成CSS3动画时是否有回调?

编程入门 行业动态 更新时间:2024-10-24 19:27:10
本文介绍了在完成CSS3动画时是否有回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有什么方法来实现回调函数在css3动画的情况下?在JavaScript动画的情况下,它可能,但没有找到任何方式在css3。

Is there any way to implement a callback function in case of css3 animation? In case of Javascript animation its possible but not finding any way to do it in css3.

我可以看到的一种方法是在动画持续时间后执行回调, t确保它总是在动画结束后立即调用。它将取决于浏览器的UI队列。我想要一个更健壮的方法。任何线索?

One way I could see is to execute callback after the animation duration but that doesn't make sure that it will always be called right after the animation ends. It will depend on the browser UI queue. I want a more robust method. Any clue?

推荐答案

是的,有。回调是一个事件,因此您必须添加一个事件侦听器来捕获它。这是一个使用jQuery的例子:

Yes, there is. The callback is an event, so you must add an event listener to catch it. This is an example with jQuery:

$("#sun").bind('oanimationend animationend webkitAnimationEnd', function() { alert("fin") });

或纯js:

element.addEventListener("webkitAnimationEnd", callfunction,false); element.addEventListener("animationend", callfunction,false); element.addEventListener("oanimationend", callfunction,false);

现场演示: jsfiddle/W3y7h/

更多推荐

在完成CSS3动画时是否有回调?

本文发布于:2023-11-25 04:10:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628268.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:回调   动画

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!