File tree Expand file tree Collapse file tree 1 file changed +22
-12
lines changed Expand file tree Collapse file tree 1 file changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -70,28 +70,38 @@ class NavBarContent extends React.Component {
7070 this . state = {
7171 opacity : this . props . willDisappear ? new Animated . Value ( 1 ) : new Animated . Value ( 0 ) ,
7272 } ;
73+
74+ this . doAnimation = this . doAnimation . bind ( this ) ;
75+ }
76+
77+ componentDidMount ( ) {
78+ // componentWillReceiveProps is not called on initial render, ensure animation is.
79+ this . doAnimation ( ) ;
7380 }
7481
7582 componentWillReceiveProps ( newProps ) {
7683 if ( newProps . route !== this . props . route ) {
7784 this . state . opacity . setValue ( this . props . willDisappear ? 1 : 0 ) ;
78-
79- setTimeout ( ( ) => {
80- Animated . timing (
81- this . state . opacity ,
82- {
83- fromValue : this . props . willDisappear ? 1 : 0 ,
84- toValue : this . props . willDisappear ? 0 : 1 ,
85- duration : 300 ,
86- easing : Easing . easeOutQuad ,
87- }
88- ) . start ( ) ;
89- } , 0 ) ;
85+ this . doAnimation ( ) ;
9086 } else if ( newProps . route === this . props . route ) {
9187 this . state . opacity . setValue ( 1 ) ;
9288 }
9389 }
9490
91+ doAnimation ( ) {
92+ setTimeout ( ( ) => {
93+ Animated . timing (
94+ this . state . opacity ,
95+ {
96+ fromValue : this . props . willDisappear ? 1 : 0 ,
97+ toValue : this . props . willDisappear ? 0 : 1 ,
98+ duration : 300 ,
99+ easing : Easing . easeOutQuad ,
100+ }
101+ ) . start ( ) ;
102+ } , 0 ) ;
103+ }
104+
95105 goBack ( ) {
96106 if ( ! this . props . willDisappear ) {
97107 this . props . goBack ( ) ;
You can’t perform that action at this time.
0 commit comments