@@ -99,7 +99,14 @@ export function resolveTransitionProps(
99
99
const durations = normalizeDuration ( duration )
100
100
const enterDuration = durations && durations [ 0 ]
101
101
const leaveDuration = durations && durations [ 1 ]
102
- const { appear, onBeforeEnter, onEnter, onLeave } = baseProps
102
+ const {
103
+ appear,
104
+ onBeforeEnter,
105
+ onEnter,
106
+ onLeave,
107
+ onEnterCancelled,
108
+ onLeaveCancelled
109
+ } = baseProps
103
110
104
111
// is appearing
105
112
if ( appear && ! instance . isMounted ) {
@@ -108,9 +115,11 @@ export function resolveTransitionProps(
108
115
enterToClass = appearToClass
109
116
}
110
117
111
- type Hook = ( el : Element , done ?: ( ) => void ) => void
118
+ type Hook =
119
+ | ( ( el : Element , done : ( ) => void ) => void )
120
+ | ( ( el : Element ) => void )
112
121
113
- const finishEnter : Hook = ( el , done ) => {
122
+ const finishEnter = ( el : Element , done ?: ( ) => void ) => {
114
123
removeTransitionClass ( el , enterToClass )
115
124
removeTransitionClass ( el , enterActiveClass )
116
125
done && done ( )
@@ -120,16 +129,22 @@ export function resolveTransitionProps(
120
129
}
121
130
}
122
131
123
- const finishLeave : Hook = ( el , done ) => {
132
+ const finishLeave = ( el : Element , done ?: ( ) => void ) => {
124
133
removeTransitionClass ( el , leaveToClass )
125
134
removeTransitionClass ( el , leaveActiveClass )
126
135
done && done ( )
127
136
}
128
137
129
138
// only needed for user hooks called in nextFrame
130
139
// sync errors are already handled by BaseTransition
131
- function callHookWithErrorHandling ( hook : Hook , args : any [ ] ) {
132
- callWithAsyncErrorHandling ( hook , instance , ErrorCodes . TRANSITION_HOOK , args )
140
+ const callHook = ( hook : Hook | undefined , args : any [ ] ) => {
141
+ hook &&
142
+ callWithAsyncErrorHandling (
143
+ hook ,
144
+ instance ,
145
+ ErrorCodes . TRANSITION_HOOK ,
146
+ args
147
+ )
133
148
}
134
149
135
150
return extend ( baseProps , {
@@ -141,7 +156,7 @@ export function resolveTransitionProps(
141
156
onEnter ( el , done ) {
142
157
nextFrame ( ( ) => {
143
158
const resolve = ( ) => finishEnter ( el , done )
144
- onEnter && callHookWithErrorHandling ( onEnter as Hook , [ el , resolve ] )
159
+ callHook ( onEnter , [ el , resolve ] )
145
160
removeTransitionClass ( el , enterFromClass )
146
161
addTransitionClass ( el , enterToClass )
147
162
if ( ! ( onEnter && onEnter . length > 1 ) ) {
@@ -158,7 +173,7 @@ export function resolveTransitionProps(
158
173
addTransitionClass ( el , leaveFromClass )
159
174
nextFrame ( ( ) => {
160
175
const resolve = ( ) => finishLeave ( el , done )
161
- onLeave && callHookWithErrorHandling ( onLeave as Hook , [ el , resolve ] )
176
+ callHook ( onLeave , [ el , resolve ] )
162
177
removeTransitionClass ( el , leaveFromClass )
163
178
addTransitionClass ( el , leaveToClass )
164
179
if ( ! ( onLeave && onLeave . length > 1 ) ) {
@@ -170,8 +185,14 @@ export function resolveTransitionProps(
170
185
}
171
186
} )
172
187
} ,
173
- onEnterCancelled : finishEnter ,
174
- onLeaveCancelled : finishLeave
188
+ onEnterCancelled ( el ) {
189
+ finishEnter ( el )
190
+ onEnterCancelled && onEnterCancelled ( el )
191
+ } ,
192
+ onLeaveCancelled ( el ) {
193
+ finishLeave ( el )
194
+ onLeaveCancelled && onLeaveCancelled ( el )
195
+ }
175
196
} as BaseTransitionProps < Element > )
176
197
}
177
198
0 commit comments