我正在使用 animate.css 制作一些动画。如果发生错误,元素应该反弹:
$target.addClass('animated bounce');
效果很好。但如果用户正在做同样的事情,则不会有第二个动画,因为已经添加了类。
所以我尝试像这样在动画之后删除类:
$target.addClass('animated bounce');
setTimeout(function(){
$target.removeClass('animated bounce');
}, 1000);
我的问题是,是否应该这样做(我不知道动画到底有多长),或者是否有重复动画的另一种解决方案?
最佳答案
你需要这样做:
$('#target').removeClass().addClass('bounce animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
$(this).removeClass();
});
$('#target')
在本例中是您元素的 ID,请根据您的需要更改它。
关于css - animate.css:重复动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34142104/