@@ -78,9 +78,10 @@ export default class Swipeable extends Component<PropType, StateType> {
78
78
this . state = {
79
79
dragX,
80
80
rowTranslation : new Animated . Value ( 0 ) ,
81
+ rowWidth : Constants . screenWidth ,
81
82
leftWidth : undefined ,
82
83
rightOffset : undefined ,
83
- rowWidth : Constants . screenWidth
84
+ measureCompleted : false
84
85
} ;
85
86
86
87
this . _updateAnimatedEvent ( props , this . state ) ;
@@ -293,9 +294,36 @@ export default class Swipeable extends Component<PropType, StateType> {
293
294
this . _animateRow ( this . _currentOffset ( ) , - rightWidth ) ;
294
295
} ;
295
296
296
- _onRowLayout = ( { nativeEvent} ) = > this . setState ( { rowWidth : nativeEvent . layout . width } ) ;
297
- _onLeftLayout = ( { nativeEvent} ) => this . setState ( { leftWidth : nativeEvent . layout . x } ) ;
298
- _onRightLayout = ( { nativeEvent} ) => this . setState ( { rightOffset : nativeEvent . layout . x } ) ;
297
+ _onRowLayout = ( { nativeEvent} ) = > this . handleMeasure ( 'rowWidth' , nativeEvent ) ;
298
+ _onLeftLayout = ( { nativeEvent} ) => this . handleMeasure ( 'leftWidth' , nativeEvent ) ;
299
+ _onRightLayout = ( { nativeEvent} ) => this . handleMeasure ( 'rightOffset' , nativeEvent ) ;
300
+
301
+ handleMeasure = ( name , nativeEvent ) => {
302
+ const { width, x} = nativeEvent . layout ;
303
+
304
+ switch ( name ) {
305
+ case 'rowWidth' :
306
+ this . rowWidth = width ;
307
+ break ;
308
+ case 'leftWidth' :
309
+ this . leftWidth = x ;
310
+ break ;
311
+ case 'rightOffset' :
312
+ this . rightOffset = x ;
313
+ break ;
314
+ default :
315
+ break ;
316
+ }
317
+
318
+ if ( this . rowWidth && this . leftWidth && this . rightOffset ) {
319
+ this . setState ( {
320
+ rowWidth : this . rowWidth ,
321
+ leftWidth : this . leftWidth ,
322
+ rightOffset : this . rightOffset ,
323
+ measureCompleted : true
324
+ } ) ;
325
+ }
326
+ } ;
299
327
300
328
render ( ) {
301
329
const {
0 commit comments