I'm trying to add and remove classes on animated elements to create a stagger/delay effect so once the animation is completed, it adds an animation out class, then once that is completed it restarts the process.
I am using animate.css for the animations.
I have created a jsFiddle here: https://jsfiddle.net/3ozfgrh2/
As you can see it plays out the first 'loop' fine but then it removes/adds the classes too early/off.
var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
$('.sticker').on(animationEnd, function() {
var $this = $(this);
$this.removeClass('bounceIn').addClass('bounceOut').on(animationEnd, function() {
setTimeout(function() {
$this.removeClass('bounceOut').addClass('bounceIn');
}, 1000);
});
});
Any thoughts?