Skip to content

Instantly share code, notes, and snippets.

@matkl
Last active August 29, 2015 14:05
Show Gist options
  • Save matkl/fb2087c5754054d6347e to your computer and use it in GitHub Desktop.
Save matkl/fb2087c5754054d6347e to your computer and use it in GitHub Desktop.
Cross browser animate function for animate.css - Vanilla JavaScript. IE10+
function animate(element, animation) {
var eventNames = [
'animationend',
'webkitAnimationEnd',
'MSAnimationEnd',
'oAnimationEnd'
];
var listeners = [];
element.classList.add('animated');
element.classList.add(animation);
eventNames.forEach(function(eventName) {
listeners.push(element.addEventListener(eventName, function() {
listeners.forEach(function(listener) {
element.removeEventListener(eventName, listener);
});
element.classList.remove('animated');
element.classList.remove(animation);
}));
});
}
@matkl
Copy link
Author

matkl commented Aug 21, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment