File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import ReactDOM from 'react-dom';
5
5
import config from './config' ;
6
6
import { timeoutsShape } from './utils/PropTypes' ;
7
7
import TransitionGroupContext from './TransitionGroupContext' ;
8
+ import { nextTick } from "./utils/nextTick"
8
9
9
10
export const UNMOUNTED = 'unmounted' ;
10
11
export const EXITED = 'exited' ;
@@ -212,7 +213,15 @@ class Transition extends React.Component {
212
213
this . cancelNextCallback ( ) ;
213
214
214
215
if ( nextStatus === ENTERING ) {
215
- this . performEnter ( mounting ) ;
216
+ // https://github.com/reactjs/react-transition-group/pull/749
217
+ // With unmountOnExit or mountOnEnter, the enter animation should happen at the transition between `exited` and `entering`.
218
+ // To make the animation happen, we have to separate each rendering and avoid being processed as batched.
219
+ if ( this . props . unmountOnExit || this . props . mountOnEnter ) {
220
+ // `exited` -> `entering`
221
+ nextTick ( ( ) => this . performEnter ( mounting ) ) ;
222
+ } else {
223
+ this . performEnter ( mounting ) ;
224
+ }
216
225
} else {
217
226
this . performExit ( ) ;
218
227
}
Original file line number Diff line number Diff line change
1
+ // polyfill for requestAnimationFrame
2
+ const rAF = typeof window !== "undefined" && typeof window . requestAnimationFrame === "function" ? window . requestAnimationFrame : cb => setTimeout ( cb , 1 )
3
+
4
+ // https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
5
+ // Note: Your callback routine must itself call requestAnimationFrame() again
6
+ // if you want to animate another frame at the next repaint. requestAnimationFrame() is 1 shot.
7
+ export const nextTick = cb => rAF ( ( ) => rAF ( cb ) )
You can’t perform that action at this time.
0 commit comments