Animate.css - Wait for animation to finish before continuing

元气小坏坏 提交于 2019-12-04 06:16:01

问题


I'm currently using Animate.css for animation around the app I'm creating. I'm looking for a way to wait for the animation to finish before continuing. Here's what I thought would of worked, but doesn't. Any help is appcieated!

$("#myDiv").addClass("animated flipOutY", function() {
  return $("#myDiv").empty();
});

回答1:


There's no cross-browser way to do this except for setting a timeout.

setTimeout($('#myDiv').empty, 500);

There are some browser-prefixed methods for this, but I think I remember them being unreliable. See this SO question: Callback on CSS transition




回答2:


If this is about CSS animations then this

$("#myDiv").addClass("animated flipOutY")
           .on('animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd', function(e) {
              $(this). ...
           });

If that animate.css uses actually transitions then you should use these events:

'transitionend webkitTransitionEnd MSTransitionEnd oTransitionEnd'


来源:https://stackoverflow.com/questions/19940603/animate-css-wait-for-animation-to-finish-before-continuing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!