React-native: PanResponder blocks touchables on android devices

Created on 19 Dec 2016  路  9Comments  路  Source: facebook/react-native

Description

PanResponder blocks TouchableHighlight and TochableOpacity if they are inside of responding View.
No mere what this functions return true or false:
onStartShouldSetPanResponderCapture: (evt, gestureState) => true,
onMoveShouldSetPanResponderCapture: (evt, gestureState) => true,

On GenyMotion Simulator all works great, set capture funtions to return false and we are good, but on nexus 6 and noname Android 4.4 device Touchables are not responding.

Solution

if we have
onStartShouldSetPanResponderCapture: (evt, gestureState) => false,
onMoveShouldSetPanResponderCapture: (evt, gestureState) => false,
inside touchables should respond to presses.

else
onStartShouldSetPanResponderCapture: (evt, gestureState) => true,
onMoveShouldSetPanResponderCapture: (evt, gestureState) => true,
shouldn't.

Additional Information

  • React Native version: 0.38
  • Platform: Android maybe on iOS too didn't check this.
  • Operating System: Windows
Locked

All 9 comments

It does not seem to work

      this.typePanRep = PanResponder.create({
          onStartShouldSetPanResponder: (evt, gestureState) => false,
          onStartShouldSetPanResponderCapture: (evt, gestureState) => false,
          onMoveShouldSetPanResponder: (evt, gestureState) => true,
          onMoveShouldSetPanResponderCapture: (evt, gestureState) => false,
          onPanResponderMove: (evt, gestureState) => {
          },
      })
<ListView
ref={listView => this._typelistView = listView}
dataSource={ds.cloneWithRowsAndSections(this.state.typeList)}
renderRow={this._renderTypeRowView.bind(this)}
{...this.typePanRep.panHandlers}
/>

PanResponder blocks the touches inside ListView in same models of android , and only sometimes.

i have the same problem :(
any ideas to fix it?

Replacing onPress with onPressIn at the TochableOpacity-Component solved the issue for me.

OnPressIn does the trick but in my case it triggers a swipe at the same time.

I have the same issue and I have asked the question on stackoverflow https://stackoverflow.com/questions/44653138/panresponder-could-not-detect-touch-if-i-touch-on-touchablestouchablehighlight
I have tried onPressIn but it does not work as expected. Sometimes it swipes while pressing
Any idea how to fix it?

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

Post a relevant snippet and I'll try to lend a hand @pie6k - just got around this issue myself by basically switching around the component order in render.

I just adjusted my "pan handle" component to be last in the stack, and within that I've placed a TouchableWithoutFeedback which receives onPress events (_on-top_ of the panResponder).

Was this page helpful?
0 / 5 - 0 ratings