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> {
273273 layout : { width : containerWidth , height : containerHeight }
274274 }
275275 } : LayoutChangeEvent ) => {
276- const { pageWidth = containerWidth , pageHeight = containerHeight } = this . props ;
276+ const { pageWidth = containerWidth , pageHeight = containerHeight , horizontal } = this . props ;
277277
278278 const initialOffset = presenter . calcOffset ( this . props , {
279279 currentPage : this . state . currentPage ,
280280 pageWidth,
281281 pageHeight
282282 } ) ;
283283
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+ }
285289 } ;
286290
287291 onMomentumScrollEnd = ( ) => {
You can’t perform that action at this time.
0 commit comments