@@ -45,8 +45,12 @@ export function removeTransitionClass (el: any, cls: string) {
4545 removeClass ( el , cls )
4646}
4747
48- export function whenTransitionEnds ( el : Element , cb : Function ) {
49- const { type, timeout, propCount } = getTransitionInfo ( el )
48+ export function whenTransitionEnds (
49+ el : Element ,
50+ expectedType : ?stirng ,
51+ cb : Function
52+ ) {
53+ const { type, timeout, propCount } = getTransitionInfo ( el , expectedType )
5054 if ( ! type ) return cb ( )
5155 const event = type === TRANSITION ? transitionEndEvent : animationEndEvent
5256 let ended = 0
@@ -69,34 +73,56 @@ export function whenTransitionEnds (el: Element, cb: Function) {
6973
7074const transformRE = / \b ( t r a n s f o r m | a l l ) ( , | $ ) /
7175
72- export function getTransitionInfo ( el : Element ) : {
73- type: ?string ,
74- propCount : number ,
75- timeout : number
76+ export function getTransitionInfo ( el : Element , expectedType ?: ? string ) : {
77+ type : ?string ;
78+ propCount : number ;
79+ timeout : number ;
7680} {
7781 const styles = window . getComputedStyle ( el )
78- const transitionProps = styles [ transitionProp + 'Property' ]
7982 const transitioneDelays = styles [ transitionProp + 'Delay' ] . split ( ', ' )
8083 const transitionDurations = styles [ transitionProp + 'Duration' ] . split ( ', ' )
84+ const transitionTimeout = getTimeout ( transitioneDelays , transitionDurations )
8185 const animationDelays = styles [ animationProp + 'Delay' ] . split ( ', ' )
8286 const animationDurations = styles [ animationProp + 'Duration' ] . split ( ', ' )
83- const transitionTimeout = getTimeout ( transitioneDelays , transitionDurations )
8487 const animationTimeout = getTimeout ( animationDelays , animationDurations )
85- const timeout = Math . max ( transitionTimeout , animationTimeout )
86- const type = timeout > 0
87- ? transitionTimeout > animationTimeout
88- ? TRANSITION
89- : ANIMATION
90- : null
91- return {
92- type,
93- timeout,
94- propCount : type
88+
89+ let type
90+ let timeout = 0
91+ let propCount = 0
92+ /* istanbul ignore if */
93+ if ( expectedType === TRANSITION ) {
94+ if ( transitionTimeout > 0 ) {
95+ type = TRANSITION
96+ timeout = transitionTimeout
97+ propCount = transitionDurations . length
98+ }
99+ } else if ( expectedType === ANIMATION ) {
100+ if ( animationTimeout > 0 ) {
101+ type = ANIMATION
102+ timeout = animationTimeout
103+ propCount = animationDurations . length
104+ }
105+ } else {
106+ timeout = Math . max ( transitionTimeout , animationTimeout )
107+ type = timeout > 0
108+ ? transitionTimeout > animationTimeout
109+ ? TRANSITION
110+ : ANIMATION
111+ : null
112+ propCount = type
95113 ? type === TRANSITION
96114 ? transitionDurations . length
97115 : animationDurations . length
98- : 0 ,
99- hasTransform : type === TRANSITION && transformRE . test ( transitionProps )
116+ : 0
117+ }
118+ const hasTransform =
119+ type === TRANSITION &&
120+ transformRE . test ( styles [ transitionProp + 'Property' ] )
121+ return {
122+ type,
123+ timeout,
124+ propCount,
125+ hasTransform
100126 }
101127}
102128
0 commit comments