cssEvents.js 983 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // XXX Should we use something like Moderniz instead of our custom detector?
  2. function whichTransitionEvent() {
  3. const el = document.createElement('fakeelement');
  4. const transitions = {
  5. transition:'transitionend',
  6. OTransition:'oTransitionEnd',
  7. MSTransition:'msTransitionEnd',
  8. MozTransition:'transitionend',
  9. WebkitTransition:'webkitTransitionEnd',
  10. };
  11. for (const t in transitions) {
  12. if (el.style[t] !== undefined) {
  13. return transitions[t];
  14. }
  15. }
  16. }
  17. function whichAnimationEvent() {
  18. const el = document.createElement('fakeelement');
  19. const transitions = {
  20. animation:'animationend',
  21. OAnimation:'oAnimationEnd',
  22. MSTransition:'msAnimationEnd',
  23. MozAnimation:'animationend',
  24. WebkitAnimation:'webkitAnimationEnd',
  25. };
  26. for (const t in transitions) {
  27. if (el.style[t] !== undefined) {
  28. return transitions[t];
  29. }
  30. }
  31. }
  32. CSSEvents = {
  33. transitionend: whichTransitionEvent(),
  34. animationend: whichAnimationEvent(),
  35. };