Animate.css - Wait for animation to finish before

2019-03-03 07:35发布

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();
});

2条回答
来,给爷笑一个
2楼-- · 2019-03-03 08:25

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

查看更多
ゆ 、 Hurt°
3楼-- · 2019-03-03 08:27

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'
查看更多
登录 后发表回答