Created
May 14, 2019 09:26
-
-
Save kieran23101/fe0ba2c88842116a4118cc2e3d9ae912 to your computer and use it in GitHub Desktop.
This function preforms an animation on an element through js
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
window.animateCSS = function(element, animationName, callback) { | |
element.classList.add('animated', animationName) | |
function handleAnimationEnd() { | |
element.classList.remove('animated', animationName) | |
element.removeEventListener('animationend', handleAnimationEnd) | |
if (typeof callback === 'function') callback() | |
} | |
element.addEventListener('animationend', handleAnimationEnd) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment