I'm not looking to trigger a CSS animation from JS, but rather the opposite.
我不打算从JS触发CSS动画,而是相反。
If I do a CSS animation via the -webkit-transition
or transition: all 1000ms
type style sheet, is there a way to trigger a JS function after the transition is done?
如果我通过-webkit-transition或transition执行CSS动画:所有1000ms类型样式表,有没有办法在转换完成后触发JS函数?
Basically I've been doing animations via javascript and I want to convert some of them to CSS animations, but I need to trigger javascript events after the animations have completed.
基本上我一直在通过javascript做动画,我想将其中的一些转换为CSS动画,但我需要在动画完成后触发javascript事件。
2 个解决方案
#1
3
box.addEventListener('webkitTransitionEnd', function( event ) {
alert( "Finished transition!" );
}, false );
See: Callback on CSS transition
请参阅:CSS过渡回调
#2
0
I think you would need javascript before the transition, to trigger it, and after it. to make some sort of callback... but my knowledge is very poor
我认为在转换之前你需要javascript来触发它,然后在它之后。做某种回调......但我的知识很差
#1
3
box.addEventListener('webkitTransitionEnd', function( event ) {
alert( "Finished transition!" );
}, false );
See: Callback on CSS transition
请参阅:CSS过渡回调
#2
0
I think you would need javascript before the transition, to trigger it, and after it. to make some sort of callback... but my knowledge is very poor
我认为在转换之前你需要javascript来触发它,然后在它之后。做某种回调......但我的知识很差