@@ -2,7 +2,7 @@ import * as React from 'react';
22import { useRef , useState } from 'react' ;
33import Align from 'rc-align' ;
44import { RefAlign } from 'rc-align/lib/Align' ;
5- import CSSMotion , { CSSMotionProps } from 'rc-motion' ;
5+ import CSSMotion , { CSSMotionProps , MotionEndEventHandler } from 'rc-motion' ;
66import classNames from 'classnames' ;
77import {
88 Point ,
@@ -133,29 +133,41 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(
133133 }
134134
135135 // ======================== 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+ } ) ;
137144
138145 function onShowPrepare ( ) {
139146 return new Promise ( resolve => {
140147 prepareResolveRef . current = resolve ;
141148 } ) ;
142149 }
143150
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+
144158 // ========================= Refs =========================
145159 React . useImperativeHandle ( ref , ( ) => ( {
146160 forceAlign,
147161 getElement : ( ) => elementRef . current ,
148162 } ) ) ;
149163
150164 // ======================== Render ========================
151- const interactiveReady = status === 'stable' || ! visible ;
152-
153165 const mergedStyle : React . CSSProperties = {
154166 ...stretchStyle ,
155167 zIndex,
156168 ...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' ,
159171 } ;
160172
161173 // Align status
0 commit comments