Skip to content

Instantly share code, notes, and snippets.

@tyler-johnson
Created October 20, 2014 22:51
Show Gist options
  • Save tyler-johnson/cb366fddb64d35fc025a to your computer and use it in GitHub Desktop.
Save tyler-johnson/cb366fddb64d35fc025a to your computer and use it in GitHub Desktop.
Determine the correct CSS3 transition end event name.
var transitionEndEventName = (function() {
var i,
undefined,
el = document.createElement('div'),
transitions = {
'transition':'transitionend',
'OTransition':'otransitionend', // oTransitionEnd in very old Opera
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd'
};
for (i in transitions) {
if (transitions.hasOwnProperty(i) && el.style[i] !== undefined) {
return transitions[i];
}
}
//TODO: throw 'TransitionEnd event is not supported in this browser';
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment