react-native-snap-carousel icon indicating copy to clipboard operation
react-native-snap-carousel copied to clipboard

Carousel not scrolling in Android when put inside a ScrollView but works in IOS.

Open sagarrs opened this issue 4 years ago • 12 comments

Is this a bug report, a feature request, or a question?

bug report

Have you followed the required steps before opening a bug report?

(Check the step you've followed - put an x character between the square brackets ([]).)

Have you made sure that it wasn't a React Native bug?

yes

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

Tested on Android Version 9 pie

Is the bug reproductible in a production environment (not a debug one)?

yes

Environment

Environment: React: 16.9.0 React native: 0.61.4 react-native-snap-carousel: ^3.8.4

Target Platform: Android (9)

Expected Behavior

carousel should scroll when inside ScrollView

Actual Behavior

Carousel not scrolling in Android when put inside a ScrollView but works in IOS.

Reproducible Demo

here is expo snack to reproduce the issue, (Please run it in your android phone) https://snack.expo.io/@sagar293/flatlist-inside-scrollview

Steps to Reproduce

(Write your steps so that anyone can reproduce the issue in the Snack demo you provided.)

  1. Create a ScrollView in that render the card as shown in the expo snack
  2. inside the card create the "Carousel" from "react-native-snap-carousel" to render the images
  3. run it in your Android device

sagarrs avatar Dec 30 '19 07:12 sagarrs

I am facing the exact same issue. Let me know if you have found the solution yet.

mohitbhansali avatar Dec 30 '19 16:12 mohitbhansali

I am facing to the same issue too.

MahefaAbel avatar Jan 25 '20 10:01 MahefaAbel

As a quick guess, this could be related to RN's Bug on Android concerning nested horizontal ScrollViews. As a workaround, try to use the ScrollView Component of react-native-gesture-handler. See https://github.com/facebook/react-native/issues/21436

smm76 avatar Feb 04 '20 15:02 smm76

same issue +1.

meiqi1992 avatar Aug 13 '20 15:08 meiqi1992

Confirmed workaround from @smm76 . I simply swapped the import and things started working on Android. Thanks so much!

matrak-jason avatar Aug 14 '20 05:08 matrak-jason

+1 Confirmed workaround from @smm76

sergey-king avatar Sep 22 '20 16:09 sergey-king

As a quick guess, this could be related to RN's Bug on Android concerning nested horizontal ScrollViews. As a workaround, try to use the ScrollView Component of react-native-gesture-handler. See https://github.com/facebook/react-native/issues/21436

I have the same issue but in a bit more complex context:

A horizontal carousel nested inside a vertical ScrollView that is essentially a horizontal FlatList item. Carousel doesn't work on Android device, works only on iOS.

Using react-native-gesture-handler's ScrollView didn't help.

I also tried the following approach as it's related, but didn't work neither: How can I have nested horizontal ScrollViews in React Native?

@smm76 @matrak-jason @sergey-king do you guys have any new information on this?

PS: Once I make the FlatList vertical, the horizontal carousel works. Therefore I believe this issue is caused by the two overlapping horizontal scrolls and it's Android specific.

mathew3 avatar Dec 03 '20 14:12 mathew3

As a quick guess, this could be related to RN's Bug on Android concerning nested horizontal ScrollViews. As a workaround, try to use the ScrollView Component of react-native-gesture-handler. See https://github.com/facebook/react-native/issues/21436

Saved my life, I have snap carousel -> scrollview (vertical) -> scrollview(horizontal) Problem was not working the horizontal scroll in android, As you mentioned, I used the scrollview of react-native-gesture-handler

Working for me as well. thanks

darkhorse-coder avatar Apr 21 '21 18:04 darkhorse-coder

As a quick guess, this could be related to RN's Bug on Android concerning nested horizontal ScrollViews. As a workaround, try to use the ScrollView Component of react-native-gesture-handler. See https://github.com/facebook/react-native/issues/21436

Thanks this worked for me

whenmoon avatar May 02 '21 10:05 whenmoon

Sorry, please allow me to advertise for my open source library! ~ I think this library react-native-reanimated-carousel will solve your problem. It is a high performance and very simple component, complete with React-Native reanimated 2

dohooo avatar Oct 08 '21 05:10 dohooo

This helped me https://github.com/gorhom/react-native-bottom-sheet/issues/311#issuecomment-794418413

alexandermirzoyan avatar Nov 30 '21 08:11 alexandermirzoyan

Thank you alexandermirzoyan! Using

<NativeViewGestureHandler disallowInterruption={true}>
   {...}
</NativeViewGestureHandler>

worked good for me in Android. Here is the source again: https://github.com/gorhom/react-native-bottom-sheet/issues/311#issuecomment-794418413

martinferrarese avatar Oct 14 '22 14:10 martinferrarese