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

Item vertical scroll interferes with carousel horizontal scroll (Android only)

Open dudeinthemirror opened this issue 4 years ago • 16 comments

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

This is a bug report

Summary: I have a carousel where each item is a card that has a title and a WebView. On Android, when attempting to scroll the web page loaded in the webview, the gesture handler of the Carousel gets fired first most of the time. On iOS, everything works fine.

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

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

Yes, it is not an issue with React Native - the iOS build works as expected.

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

Android only.

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

Yes

Environment

Environment: React: 16.11.0 React native: 0.62.0 react-native-snap-carousel: 4.0.0-beta.5 Target Platform: Android (10.0) iOS (13)

Expected Behavior

On Android, the user should be able to scroll the web page (vertically) without triggering a carousel horizontal scroll.

Actual Behavior

On Android, most attempts to scroll the web page (vertically) will trigger a carousel horizontal scroll

Here are gifs showing the issue. The iOS build works as expected, but for Android it's virtually impossible to scroll a webpage vertically without triggering the horizontal Carousel scroll.

iOS

carousel_example_ios

Android

carousel_example_android

Reproducible Demo

https://github.com/dudeinthemirror/carousel-example

Steps to Reproduce

iOS

  1. Initialize, build and run iOS (yarn, yarn start, pod install, yarn ios)
  2. Cards with title and webview will load in the Carousel
  3. Scroll up and down in a webpage
  4. Observe that everything works as expected (no interference between the vertical and horizontal scroll)

Android

  1. Initialize, build and run Android (yarn, yarn start, pod install, yarn android)
  2. Cards with title and webview will load in the Carousel
  3. Scroll up and down in a webpage
  4. Observe that it's virtually impossible to scroll a webpage vertically without triggering the Carousel horizontal scroll

Thank you for your time!

dudeinthemirror avatar Oct 20 '20 17:10 dudeinthemirror

hey @dudeinthemirror I'm also struggling with this issue. Did you figure out any workarounds?

goleary avatar Dec 15 '20 05:12 goleary

hey @goleary, not yet. I posted on SO as well, nothing so far. Let me know if you figure out something, thanks 🍻

dudeinthemirror avatar Dec 15 '20 13:12 dudeinthemirror

Thanks for following up @dudeinthemirror. Someone on my team rigged something to spit scroll events from the webview into the react native application that will conditionally disable swiping on the carousel...sadly it doesn't work very well and slows the app down so I was hoping you'd found a better solution.

I'll let you know if we get it to work better or come up with a better solution.

goleary avatar Dec 15 '20 20:12 goleary

appreciate it @goleary ! BTW, feel free to use my demo repo that I put together for this issue: https://github.com/dudeinthemirror/carousel-example

dudeinthemirror avatar Dec 15 '20 22:12 dudeinthemirror

hey @dudeinthemirror I ended up switching to another package to get around this limitation:

https://github.com/callstack/react-native-viewpager

Here's a snack I made where you can play with it: https://snack.expo.io/@goleary/2d70d1

Looks like it doesn't work on the web, but it works in Android & iOS (which is all we need).

Hope it's helpful!

goleary avatar Jan 28 '21 01:01 goleary

hey @goleary thanks for following up on this! This looks like a viable solution and the fact that it's published under the @react-native-community namespace is reassuring ;) I'll make the switch in our project as well.

dudeinthemirror avatar Jan 28 '21 15:01 dudeinthemirror

@dudeinthemirror

The viewpager works a million times better on Android. But it has one annoying issue on iOS. The webview doesn't load when off screen (unlike with this package), so when you swipe from one to the next it's blank for a bit.

I've got a PR out that I hope will fix this, but it could be a bit before it makes it into that package.

Just thought I'd let you know in case it affects your decision to move over or not.

goleary avatar Jan 30 '21 16:01 goleary

Any solution for this?

vikrantnegi avatar Apr 13 '21 06:04 vikrantnegi

neither of the issues have been fixed in either repo...so I use the snap carousel on ios & the view pager on android 😬

goleary avatar Apr 20 '21 04:04 goleary

But how to create asnap carousel type carousel with first and last item visible using pager view.

vikrantnegi avatar Apr 20 '21 08:04 vikrantnegi

ahh I have no idea. I use full screen webviews with both.

goleary avatar Apr 20 '21 16:04 goleary

@vikrantnegi from what I've tried so far, if you use viewpager you can't have it show previews (i.e. part of the previous page (left) and part of the next page (right)). The Ux is sub-par IMO.

dudeinthemirror avatar Apr 21 '21 00:04 dudeinthemirror

@dudeinthemirror You are right, there is no support for showing previews in react native pager.

vikrantnegi avatar Apr 21 '21 04:04 vikrantnegi

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 04:10 dohooo

我的解决方法是让webView占满高度,然后放在scrollView里面,让scrollView去滚动而不是让webView滚动,这样就不会出现这种情况了

xjdqq avatar Mar 02 '22 01:03 xjdqq

any workarounds ?

arasovic avatar Apr 04 '22 08:04 arasovic