@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
import { useRef , useState } from 'react' ;
3
3
import Align from 'rc-align' ;
4
4
import { RefAlign } from 'rc-align/lib/Align' ;
5
- import CSSMotion , { CSSMotionProps } from 'rc-motion' ;
5
+ import CSSMotion , { CSSMotionProps , MotionEndEventHandler } from 'rc-motion' ;
6
6
import classNames from 'classnames' ;
7
7
import {
8
8
Point ,
@@ -133,29 +133,41 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(
133
133
}
134
134
135
135
// ======================== Motion ========================
136
- const motion = getMotion ( props ) ;
136
+ const motion = { ...getMotion ( props ) } ;
137
+ [ 'onAppearEnd' , 'onEnterEnd' , 'onLeaveEnd' ] . forEach ( eventName => {
138
+ const originHandler : MotionEndEventHandler = motion [ eventName ] ;
139
+ motion [ eventName ] = ( element , event ) => {
140
+ goNextStatus ( ) ;
141
+ return originHandler ?.( element , event ) ;
142
+ } ;
143
+ } ) ;
137
144
138
145
function onShowPrepare ( ) {
139
146
return new Promise ( resolve => {
140
147
prepareResolveRef . current = resolve ;
141
148
} ) ;
142
149
}
143
150
151
+ // Go to stable directly when motion not provided
152
+ React . useEffect ( ( ) => {
153
+ if ( ! motion . motionName && status === 'motion' ) {
154
+ goNextStatus ( ) ;
155
+ }
156
+ } , [ motion . motionName , status ] ) ;
157
+
144
158
// ========================= Refs =========================
145
159
React . useImperativeHandle ( ref , ( ) => ( {
146
160
forceAlign,
147
161
getElement : ( ) => elementRef . current ,
148
162
} ) ) ;
149
163
150
164
// ======================== Render ========================
151
- const interactiveReady = status === 'stable' || ! visible ;
152
-
153
165
const mergedStyle : React . CSSProperties = {
154
166
...stretchStyle ,
155
167
zIndex,
156
168
...style ,
157
- opacity : interactiveReady ? undefined : 0 ,
158
- pointerEvents : interactiveReady ? undefined : 'none' ,
169
+ opacity : status === 'motion' || status === 'stable' ? undefined : 0 ,
170
+ pointerEvents : status === 'stable' ? undefined : 'none' ,
159
171
} ;
160
172
161
173
// Align status
0 commit comments