Skip to content

Instantly share code, notes, and snippets.

@adamfaux85
Last active February 21, 2018 12:51
Show Gist options
  • Save adamfaux85/add493955e1dfb2fac7ccab0f087117b to your computer and use it in GitHub Desktop.
Save adamfaux85/add493955e1dfb2fac7ccab0f087117b to your computer and use it in GitHub Desktop.
Add / Remove animation classes in jQuery
## TOGGLE CLASSES IN JAVASCRIPT AFTER ANIMATION END
// Example taken from Animation.css
// - https://daneden.github.io/animate.css/
function testAnim(x) {
$('#animationSandbox').removeClass().addClass(x + ' animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
$(this).removeClass();
});
};
$(document).ready(function(){
$('.js--triggerAnimation').click(function(e){
e.preventDefault();
var anim = $('.js--animations').val();
testAnim(anim);
});
$('.js--animations').change(function(){
var anim = $(this).val();
testAnim(anim);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment