Skip to content

Instantly share code, notes, and snippets.

@hsnaydd
Created February 17, 2015 09:57
Show Gist options
  • Save hsnaydd/110e5a8db79a1d0c1a24 to your computer and use it in GitHub Desktop.
Save hsnaydd/110e5a8db79a1d0c1a24 to your computer and use it in GitHub Desktop.
which transition Event js
/* From Modernizr */
function whichTransitionEvent(){
var t;
var el = document.createElement('fakeelement');
var transitions = {
'transition':'transitionend',
'OTransition':'oTransitionEnd',
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd'
}
for(t in transitions){
if( el.style[t] !== undefined ){
return transitions[t];
}
}
}
/* Listen for a transition! */
var transitionEvent = whichTransitionEvent();
transitionEvent && e.addEventListener(transitionEvent, function() {
console.log('Transition complete! This is the callback, no library needed!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment