Last active
November 23, 2023 22:43
-
-
Save O-Zone/7230245 to your computer and use it in GitHub Desktop.
Get the name of the browsers transitionEnd event. After calling this, window.transitionEnd will contain the browser specific name of the transitionEnd event. This is an extract of EvandroLG's transitionEnd snippet, without all support for testing different elements and using cache.
This file contains hidden or 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
(function (window) { | |
var transitions = { | |
'transition': 'transitionend', | |
'WebkitTransition': 'webkitTransitionEnd', | |
'MozTransition': 'transitionend', | |
'OTransition': 'otransitionend' | |
}, | |
elem = document.createElement('div'); | |
for(var t in transitions){ | |
if(typeof elem.style[t] !== 'undefined'){ | |
window.transitionEnd = transitions[t]; | |
break; | |
} | |
} | |
})(window); |
Perhaps also consider:
if (typeof elem.style[t] !== 'undefined') {
....
Just in case undefined was overwrote.
Thank you @ossreleasefeed - hereby updated! :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @Imignot!
Both valid improvements - I have updated the gist! :-)