daily pastebin goal
48%
SHARE
TWEET

Untitled

a guest Mar 21st, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* From Modernizr */
  2. function whichTransitionEvent() {
  3.     var t;
  4.     var el = document.createElement('fakeelement');
  5.     var transitions = {
  6.         'transition': 'transitionend',
  7.         'OTransition': 'oTransitionEnd',
  8.         'MozTransition': 'transitionend',
  9.         'WebkitTransition': 'webkitTransitionEnd'
  10.     }
  11.  
  12.     for (t in transitions) {
  13.         if (el.style[t] !== undefined) {
  14.             return transitions[t];
  15.         }
  16.     }
  17. }
  18.  
  19. /* Listen for a transition! */
  20. var transitionEvent = whichTransitionEvent();
  21.  
  22.  
  23. const
  24.     onTransitionEnd = function (el, fn) {
  25.         // console.log('entering here...', fn);
  26.         transitionEvent && el.addEventListener(transitionEvent, function() {
  27.             // console.log('done!');
  28.             fn();
  29.         });
  30.     };
  31.  
  32. export default onTransitionEnd;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top