This is a helper which adds onTransitionEnd() to EventTarget.
Inspired from bootstrap’s implementation, but without any jQuery dependency.
It checks which transitionEnd is supported by the client:
'webkitTransitionEnd', 'transitionend', 'oTransitionEnd otransitionend', 'transitionend'
And if it’s not supported (IE8 etc.) it will dispatch an transitionend event after the provided transitionDuration.
Unlike target.addEventListener('transitionend', fn), this will not trigger when a child has finished it’s transition.
target.onTransitionEnd(listener, transitionDuration);Example:
document.querySelector('.button').onTransitionEnd(() => {
// your code
}, 1000);