@@ -29,15 +29,15 @@ export class AnimationHook {
29
29
}
30
30
31
31
// code extracted from vue
32
- var raf = window . requestAnimationFrame
33
- var TRANSITION = 'transition'
34
- var ANIMATION = 'animation'
32
+ const raf = window . requestAnimationFrame
33
+ const TRANSITION = 'transition'
34
+ const ANIMATION = 'animation'
35
35
36
36
// Transition property/event sniffing
37
- var transitionProp = 'transition'
38
- var transitionEndEvent = 'transitionend'
39
- var animationProp = 'animation'
40
- var animationEndEvent = 'animationend'
37
+ const transitionProp = 'transition'
38
+ const transitionEndEvent = 'transitionend'
39
+ const animationProp = 'animation'
40
+ const animationEndEvent = 'animationend'
41
41
42
42
function nextFrame ( fn ) {
43
43
raf ( function ( ) {
@@ -49,18 +49,18 @@ function whenTransitionEnds (
49
49
el ,
50
50
cb
51
51
) {
52
- var ref = getTransitionInfo ( el )
53
- var type = ref . type
54
- var timeout = ref . timeout
55
- var propCount = ref . propCount
52
+ const ref = getTransitionInfo ( el )
53
+ const type = ref . type
54
+ const timeout = ref . timeout
55
+ const propCount = ref . propCount
56
56
if ( ! type ) { return cb ( ) }
57
- var event = type === TRANSITION ? transitionEndEvent : animationEndEvent
58
- var ended = 0
59
- var end = function ( ) {
57
+ const event = type === TRANSITION ? transitionEndEvent : animationEndEvent
58
+ let ended = 0
59
+ const end = function ( ) {
60
60
el . removeEventListener ( event , onEnd )
61
61
cb ( )
62
62
}
63
- var onEnd = function ( e ) {
63
+ const onEnd = function ( e ) {
64
64
if ( e . target === el ) {
65
65
if ( ++ ended >= propCount ) {
66
66
end ( )
@@ -76,29 +76,25 @@ function whenTransitionEnds (
76
76
}
77
77
78
78
function getTransitionInfo ( el ) {
79
- var styles = window . getComputedStyle ( el )
79
+ const styles = window . getComputedStyle ( el )
80
80
// JSDOM may return undefined for transition properties
81
- var transitionDelays = ( styles [ transitionProp + 'Delay' ] || '' ) . split ( ', ' )
82
- var transitionDurations = ( styles [ transitionProp + 'Duration' ] || '' ) . split ( ', ' )
83
- var transitionTimeout = getTimeout ( transitionDelays , transitionDurations )
84
- var animationDelays = ( styles [ animationProp + 'Delay' ] || '' ) . split ( ', ' )
85
- var animationDurations = ( styles [ animationProp + 'Duration' ] || '' ) . split ( ', ' )
86
- var animationTimeout = getTimeout ( animationDelays , animationDurations )
87
-
88
- var type
89
- var timeout = 0
90
- var propCount = 0
91
-
92
- timeout = Math . max ( transitionTimeout , animationTimeout )
93
- type = timeout > 0
81
+ const transitionDelays = ( styles [ transitionProp + 'Delay' ] || '' ) . split ( ', ' )
82
+ const transitionDurations = ( styles [ transitionProp + 'Duration' ] || '' ) . split ( ', ' )
83
+ const transitionTimeout = getTimeout ( transitionDelays , transitionDurations )
84
+ const animationDelays = ( styles [ animationProp + 'Delay' ] || '' ) . split ( ', ' )
85
+ const animationDurations = ( styles [ animationProp + 'Duration' ] || '' ) . split ( ', ' )
86
+ const animationTimeout = getTimeout ( animationDelays , animationDurations )
87
+
88
+ const timeout = Math . max ( transitionTimeout , animationTimeout )
89
+ const type = timeout > 0
94
90
? transitionTimeout > animationTimeout
95
- ? TRANSITION
96
- : ANIMATION
91
+ ? TRANSITION
92
+ : ANIMATION
97
93
: null
98
- propCount = type
94
+ const propCount = type
99
95
? type === TRANSITION
100
- ? transitionDurations . length
101
- : animationDurations . length
96
+ ? transitionDurations . length
97
+ : animationDurations . length
102
98
: 0
103
99
104
100
return {
0 commit comments