@@ -169,47 +169,49 @@ var ModalBox = createReactClass({
169169 * Open animation for the backdrop, will fade in
170170 */
171171 animateBackdropOpen : function ( ) {
172- if ( this . state . isAnimateBackdrop ) {
172+ if ( this . state . isAnimateBackdrop && this . state . animBackdrop ) {
173173 this . state . animBackdrop . stop ( ) ;
174174 }
175+ this . setState ( { isAnimateBackdrop : true } ) ;
175176
176177 let animBackdrop = Animated . timing (
177178 this . state . backdropOpacity ,
178179 {
179180 toValue : 1 ,
180- duration : this . props . animationDuration
181+ duration : this . props . animationDuration ,
182+ easing : this . props . easing ,
183+ useNativeDriver : true ,
181184 }
182- ) ;
183-
184- this . setState ( {
185- isAnimateBackdrop : true ,
186- animBackdrop
187- } , ( ) => {
188- this . state . animBackdrop . start ( ) ;
185+ ) . start ( ( ) => {
186+ this . setState ( {
187+ isAnimateBackdrop : false ,
188+ animBackdrop
189+ } ) ;
189190 } ) ;
190191 } ,
191192
192193 /*
193194 * Close animation for the backdrop, will fade out
194195 */
195196 animateBackdropClose : function ( ) {
196- if ( this . state . isAnimateBackdrop ) {
197+ if ( this . state . isAnimateBackdrop && this . state . animBackdrop ) {
197198 this . state . animBackdrop . stop ( ) ;
198199 }
200+ this . setState ( { isAnimateBackdrop : true } ) ;
199201
200202 let animBackdrop = Animated . timing (
201203 this . state . backdropOpacity ,
202204 {
203205 toValue : 0 ,
204- duration : this . props . animationDuration
206+ duration : this . props . animationDuration ,
207+ easing : this . props . easing ,
208+ useNativeDriver : true ,
205209 }
206- ) ;
207-
208- this . setState ( {
209- isAnimateBackdrop : false ,
210- animBackdrop
211- } , ( ) => {
212- this . state . animBackdrop . start ( ) ;
210+ ) . start ( ( ) => {
211+ this . setState ( {
212+ isAnimateBackdrop : false ,
213+ animBackdrop
214+ } ) ;
213215 } ) ;
214216 } ,
215217
@@ -249,17 +251,15 @@ var ModalBox = createReactClass({
249251 toValue : positionDest ,
250252 duration : this . props . animationDuration ,
251253 easing : this . props . easing ,
254+ useNativeDriver : true ,
252255 }
253- ) ;
254-
255- this . setState ( {
256- isAnimateOpen : false ,
257- animOpen,
258- positionDest
259- } , ( ) => {
260- animOpen . start ( ( ) => {
261- if ( ! this . state . isOpen && this . props . onOpened ) this . props . onOpened ( ) ;
256+ ) . start ( ( ) => {
257+ this . setState ( {
258+ isAnimateOpen : false ,
259+ animOpen,
260+ positionDest
262261 } ) ;
262+ if ( this . props . onOpened ) this . props . onOpened ( ) ;
263263 } ) ;
264264 } )
265265 } ) ;
@@ -293,17 +293,17 @@ var ModalBox = createReactClass({
293293 this . state . position ,
294294 {
295295 toValue : this . props . entry === 'top' ? - this . state . containerHeight : this . state . containerHeight ,
296- duration : this . props . animationDuration
296+ duration : this . props . animationDuration ,
297+ easing : this . props . easing ,
298+ useNativeDriver : true ,
297299 }
298- ) ;
299-
300- this . setState ( {
301- isAnimateClose : false ,
302- animClose
303- } , ( ) => {
304- animClose . start ( ( ) => {
305- if ( this . props . onClosed ) this . props . onClosed ( ) ;
300+ ) . start ( ( ) => {
301+ // Keyboard.dismiss(); // make this optional. Easily user defined in .onClosed() callback
302+ this . setState ( {
303+ isAnimateClose : false ,
304+ animClose
306305 } ) ;
306+ if ( this . props . onClosed ) this . props . onClosed ( ) ;
307307 } ) ;
308308 } ) ;
309309 } ,
@@ -479,6 +479,7 @@ if (!this.props.coverScreen) return content;
479479 }
480480 } }
481481 supportedOrientations = { [ 'landscape' , 'portrait' , 'portrait-upside-down' ] } transparent visible = { visible }
482+ hardwareAccelerated = { true }
482483 >
483484 { content }
484485 </ Modal >
0 commit comments