Created
May 12, 2020 16:56
-
-
Save minimul/8cbc4ea0330192e8c958483cf1ec2ded to your computer and use it in GitHub Desktop.
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
export default function animateCSS({ element, classes = [], callback }) { | |
element.classList.add(...classes) | |
function handleAnimationEnd() { | |
element.classList.remove(...classes) | |
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