summaryrefslogtreecommitdiffstats
path: root/client/lib/cssEvents.js
blob: 39c3fb90846e92bdbcd05c42768b26e50d267e6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// XXX Should we use something like Moderniz instead of our custom detector?

function whichTransitionEvent() {
  const el = document.createElement('fakeelement');
  const transitions = {
    transition:'transitionend',
    OTransition:'oTransitionEnd',
    MSTransition:'msTransitionEnd',
    MozTransition:'transitionend',
    WebkitTransition:'webkitTransitionEnd',
  };

  for (const t in transitions) {
    if (el.style[t] !== undefined) {
      return transitions[t];
    }
  }
}

function whichAnimationEvent() {
  const el = document.createElement('fakeelement');
  const transitions = {
    animation:'animationend',
    OAnimation:'oAnimationEnd',
    MSTransition:'msAnimationEnd',
    MozAnimation:'animationend',
    WebkitAnimation:'webkitAnimationEnd',
  };

  for (const t in transitions) {
    if (el.style[t] !== undefined) {
      return transitions[t];
    }
  }
}

CSSEvents = {
  transitionend: whichTransitionEvent(),
  animationend: whichAnimationEvent(),
};