Skip to content

Instantly share code, notes, and snippets.

@kieran23101
Created May 14, 2019 09:26
Show Gist options
  • Save kieran23101/fe0ba2c88842116a4118cc2e3d9ae912 to your computer and use it in GitHub Desktop.
Save kieran23101/fe0ba2c88842116a4118cc2e3d9ae912 to your computer and use it in GitHub Desktop.
This function preforms an animation on an element through js
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