File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -273,15 +273,19 @@ class Carousel extends Component<CarouselProps, CarouselState> {
273
273
layout : { width : containerWidth , height : containerHeight }
274
274
}
275
275
} : LayoutChangeEvent ) => {
276
- const { pageWidth = containerWidth , pageHeight = containerHeight } = this . props ;
276
+ const { pageWidth = containerWidth , pageHeight = containerHeight , horizontal } = this . props ;
277
277
278
278
const initialOffset = presenter . calcOffset ( this . props , {
279
279
currentPage : this . state . currentPage ,
280
280
pageWidth,
281
281
pageHeight
282
282
} ) ;
283
283
284
- this . setState ( { containerWidth, pageWidth, pageHeight, initialOffset} ) ;
284
+ // NOTE: This is to avoid resetting containerWidth to 0 - an issue that happens
285
+ // on Android in some case when onLayout is re-triggered
286
+ if ( ( horizontal && containerWidth ) || ( ! horizontal && containerHeight ) ) {
287
+ this . setState ( { containerWidth, pageWidth, pageHeight, initialOffset} ) ;
288
+ }
285
289
} ;
286
290
287
291
onMomentumScrollEnd = ( ) => {
You can’t perform that action at this time.
0 commit comments