@@ -78,6 +78,9 @@ interface PopupState {
7878 status : PopupStatus ;
7979 prevVisible : boolean ;
8080 alignClassName : string ;
81+
82+ /** Record for CSSMotion is working or not */
83+ inMotion : boolean ;
8184}
8285
8386interface AlignRefType {
@@ -96,6 +99,8 @@ class Popup extends Component<PopupProps, PopupState> {
9699 status : null ,
97100 prevVisible : null , // eslint-disable-line react/no-unused-state
98101 alignClassName : null ,
102+
103+ inMotion : false ,
99104 } ;
100105
101106 public popupRef = React . createRef < HTMLDivElement > ( ) ;
@@ -108,7 +113,7 @@ class Popup extends Component<PopupProps, PopupState> {
108113
109114 static getDerivedStateFromProps (
110115 { visible, ...props } : PopupProps ,
111- { prevVisible, status } : PopupState ,
116+ { prevVisible, status, inMotion } : PopupState ,
112117 ) {
113118 const newState : Partial < PopupState > = { prevVisible : visible , status } ;
114119
@@ -117,12 +122,11 @@ class Popup extends Component<PopupProps, PopupState> {
117122 if ( prevVisible === null && visible === false ) {
118123 // Init render should always be stable
119124 newState . status = 'stable' ;
125+ newState . inMotion = false ;
120126 } else if ( visible !== prevVisible ) {
121- if (
122- visible ||
123- ( supportMotion ( mergedMotion ) &&
124- [ 'motion' , 'AfterMotion' , 'stable' ] . includes ( status ) )
125- ) {
127+ newState . inMotion = false ;
128+
129+ if ( visible || ( supportMotion ( mergedMotion ) && inMotion ) ) {
126130 newState . status = null ;
127131 } else {
128132 newState . status = 'stable' ;
@@ -322,6 +326,14 @@ class Popup extends Component<PopupProps, PopupState> {
322326 mergedMotionVisible = false ;
323327 }
324328
329+ // Update trigger to tell if is in motion
330+ [ 'onEnterStart' , 'onAppearStart' , 'onLeaveStart' ] . forEach ( event => {
331+ mergedMotion [ event ] = ( ...args ) => {
332+ mergedMotion ?. [ event ] ?.( ...args ) ;
333+ this . setState ( { inMotion : true } ) ;
334+ } ;
335+ } ) ;
336+
325337 // ================== Align ==================
326338 const mergedAlignDisabled =
327339 ! visible ||
0 commit comments