Last active
October 25, 2017 14:21
-
-
Save radist2s/7ac240782ab847bea202 to your computer and use it in GitHub Desktop.
Get transition complete event name
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
var transitionEventName | |
function getTransitionEndEventName() { | |
if (transitionEventName !== undefined) { | |
return transitionEventName | |
} | |
var detectedTransition, | |
el = document.createElement('transitiondetector'), | |
transitions = { | |
'transition': 'transitionend', | |
// see also http://ianlunn.co.uk/articles/opera-12-otransitionend-bugs-and-workarounds/ | |
'OTransition': 'oTransitionEnd', | |
'MozTransition': 'transitionend', | |
'webkitTransition': 'webkitTransitionEnd' | |
} | |
Object.keys(transitions).some(function (transition) { | |
if (el.style[transition] !== undefined) { | |
detectedTransition = transitions[transition] | |
return true | |
} | |
return false | |
}) | |
if (!detectedTransition) { | |
detectedTransition = false | |
} | |
return (transitionEventName = detectedTransition) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment