LoginSignup
1
1

More than 5 years have passed since last update.

animate.css で何回もアニメーションさせたいがremoveClass()でうまく行かなかった話

Last updated at Posted at 2016-01-23
function doSomething(elem){
  elem.removeClass('animated bounceIn').addClass('animated bounceIn');
}

doSomething() を呼び出すたびにアニメーションさせようとしてもできなかった。

elem.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
  elem.removeClass('animated bounceIn');
});
elem.addClass('animated bounceIn');

とする必要があるらしい。

長ったらしいので

animate.js
var animate = {
  do: function(elem, type){
    elem.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
      elem.removeClass('animated '+ type);
    });
    elem.addClass('animated '+ type);
  }
}

というの作って animate.do(elem, 'bounceIn') で呼び出せるようにして解決した

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1