@@ -5,14 +5,15 @@ import './CSSMotion.less';
55
66interface DemoState {
77 show : boolean ;
8+ forceRender : boolean ;
89 motionLeaveImmediately : boolean ;
910 removeOnLeave : boolean ;
1011 hasMotionClassName : boolean ;
1112 prepare : boolean ;
1213}
1314
1415async function forceDelay ( ) : Promise < void > {
15- return new Promise ( ( resolve ) => {
16+ return new Promise ( resolve => {
1617 setTimeout ( resolve , 2000 ) ;
1718 } ) ;
1819}
@@ -32,6 +33,7 @@ const Div = React.forwardRef<HTMLDivElement, any>((props, ref) => {
3233class Demo extends React . Component < { } , DemoState > {
3334 state : DemoState = {
3435 show : true ,
36+ forceRender : false ,
3537 motionLeaveImmediately : false ,
3638 removeOnLeave : true ,
3739 hasMotionClassName : true ,
@@ -48,6 +50,10 @@ class Demo extends React.Component<{}, DemoState> {
4850 this . setState ( ( { prepare } ) => ( { prepare : ! prepare } ) ) ;
4951 } ;
5052
53+ onForceRender = ( ) => {
54+ this . setState ( ( { forceRender } ) => ( { forceRender : ! forceRender } ) ) ;
55+ } ;
56+
5157 onRemoveOnLeave = ( ) => {
5258 this . setState ( ( { removeOnLeave } ) => ( { removeOnLeave : ! removeOnLeave } ) ) ;
5359 } ;
@@ -84,6 +90,7 @@ class Demo extends React.Component<{}, DemoState> {
8490 render ( ) {
8591 const {
8692 show,
93+ forceRender,
8794 motionLeaveImmediately,
8895 removeOnLeave,
8996 hasMotionClassName,
@@ -106,6 +113,15 @@ class Demo extends React.Component<{}, DemoState> {
106113 hasMotionClassName
107114 </ label >
108115
116+ < label >
117+ < input
118+ type = "checkbox"
119+ onChange = { this . onForceRender }
120+ checked = { forceRender }
121+ /> { ' ' }
122+ forceRender
123+ </ label >
124+
109125 < label >
110126 < input
111127 type = "checkbox"
@@ -130,6 +146,7 @@ class Demo extends React.Component<{}, DemoState> {
130146 < h2 > With Transition Class</ h2 >
131147 < CSSMotion
132148 visible = { show }
149+ forceRender = { forceRender }
133150 motionName = { hasMotionClassName ? 'transition' : null }
134151 removeOnLeave = { removeOnLeave }
135152 leavedClassName = "hidden"
@@ -140,7 +157,7 @@ class Demo extends React.Component<{}, DemoState> {
140157 onLeaveActive = { this . onCollapse }
141158 onEnterEnd = { this . skipColorTransition }
142159 onLeaveEnd = { this . skipColorTransition }
143- onVisibleChanged = { ( visible ) => {
160+ onVisibleChanged = { visible => {
144161 console . log ( 'Visible Changed:' , visible ) ;
145162 } }
146163 >
@@ -158,6 +175,7 @@ class Demo extends React.Component<{}, DemoState> {
158175 < h2 > With Animation Class</ h2 >
159176 < CSSMotion
160177 visible = { show }
178+ forceRender = { forceRender }
161179 motionName = { hasMotionClassName ? 'animation' : null }
162180 removeOnLeave = { removeOnLeave }
163181 leavedClassName = "hidden"
0 commit comments