Skip to content

Instantly share code, notes, and snippets.

@stmn
Created March 6, 2015 13:46
Show Gist options
  • Save stmn/97cd53f1518b4a66ece8 to your computer and use it in GitHub Desktop.
Save stmn/97cd53f1518b4a66ece8 to your computer and use it in GitHub Desktop.
My function to handle animate.css
function animate(selector, animation, after, reset){
var $selector = $(selector);
setTimeout(function(){
if(typeof reset == 'undefined'){
reset = true;
}
$selector.addClass('animated '+animation).show();
if(typeof after != 'undefined'){
$selector.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(e){
after.call(this, e);
if(reset == true){
$(this).removeClass('animated '+animation);
}
});
} else {
$selector.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(e){
$(this).removeClass('animated '+animation);
});
}
}, 0);
return $selector;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment