facebook/react-native

[ScrollView] Shouldn't become responder if scrollEnabled is false

hayeah opened this issue · 6 comments

I am doing a sortable list proof-of-concept with ReactNative. One of the effects I want to achieve is to auto-scroll a long list if the dragged item is near the bottom (or top) of the screen. Like so:

sortable-list-native-demo

To prevent scroll view from scrolling while an item is dragged, I set ScrollView's "scrollEnabled" prop to false, which seems to do the trick. The only problem is if I use the scrollTo method to programmatically scroll, the scrollView mistakenly thinks a user-initiated scroll event occurred, and tries to steal the responder status.

The chain of events is illustrated by these diagrams:

scrollview-responder-stealing

The way to fix this problem is to check whether scrollEnabled is false in scrollResponderHandleScrollShouldSetResponder.

@hayeah awesome demo! I was looking for a solution like this. Is the code open sourced for the sortable list?

👍

bakso commented

@vjeux @brentvatne @ide @spicyj
Awesome demo! I was looking for a solution like this, do you have a solution for this situation now?

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/scrollview-shouldnt-become-responder-if-scrollenabled-is-false

ProductPains helps the community prioritize the most important issues thanks to its voting feature.
It is easy to use - just login with GitHub.

Also, if this issue is a bug, please consider sending a PR with a fix.
We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.