facebook/react-native

onPanResponderTerminationRequest is not working.

jihopark opened this issue · 10 comments

I want to make onPanResponderTerminationRequest: (evt, gestureState)=>false,

so that parent ListView won't take away the gesture but it doesn't seem like working properly..

Does anyone know why? I am looking into the library but still cannot find why.

Hey jihopark, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!

I seem to be experiencing this as well. I have some draggable Accessory components on top of the ViewPagerAndroid component. When dragging an Accessory component horizontally the lifecycle method onShouldBlockNativeResponder is called but return value is not respected. onPanResponderTerminate is called and the ViewPagerAndroid takes over. onPanResponderTerminationRequest was never called.

Hey @jihopark, we're a small team and rely on the community to fix issues that don't affect fb apps. If you're sure this is a bug can you send a pull request with a fix?

@rpastorelle I'm running into the same problem with ViewPagerAndroid. onPanResponderTerminationRequest is never called. Do you solve the problem?

I'm running into a similar problem. I have a View with a PanResponder that sits inside of a ScrollView. My onShouldBlockNativeResponder handler is getting ran, but the return value gets ignored. And I can't get the onPanResponderTerminationRequest to ever get called. I can go into more detail if needed.

Any movement anywhere on looking into this or solving it? Have anyone who previously posted here find a solution?

@smallpath It was a while ago but I believe this was the hack that hid the problem for me:

onMoveShouldSetPanResponder: (e, gestureState) => {
        if (
          Platform.OS == 'android'
          && (gestureState.dx < 1 && gestureState.dx > -1)
          && (gestureState.dy < 1 && gestureState.dy > -1)
        ) {
          return false;
        }

        return true;
}

I was having the same problem. onPanResponderTerminate gets called immediately when the user scrolls the parent's ListView..

I checked the source code and found this:

Scrolled views automatically become responder. The reasoning is that a platform scroll view that isn't built on top of the responder system has began scrolling, and the active responder must now be notified that the interaction is no longer locked to it - the system has taken over.

https://github.com/facebook/react/blob/master/src/renderers/shared/stack/event/eventPlugins/ResponderEventPlugin.js#L151-L154

So I think that explains why the ListView takes over...

Not sure if that's the correct answer, but shouldn't you add scrollEnabled={false} to your ListView while you are handling the gesture ?

Closing this issue because it has been inactive for a while. If you think it should still be opened let us know why.