Last active
February 21, 2018 12:51
-
-
Save adamfaux85/add493955e1dfb2fac7ccab0f087117b to your computer and use it in GitHub Desktop.
Add / Remove animation classes in jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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