Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PanResponder onPanResponderRelease doesn't calls on Android #9447

Closed
shahen94 opened this issue Aug 17, 2016 · 11 comments
Closed

PanResponder onPanResponderRelease doesn't calls on Android #9447

shahen94 opened this issue Aug 17, 2016 · 11 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@shahen94
Copy link

shahen94 commented Aug 17, 2016

I have this code in my render function.

<Animated.View
        style={[styles.wrap, { left }]}
        {...this.scrollResponder.panHandlers}
      >
        {initialRender &&
          <View style={styles.wrap} {...this.listViewResponder.panHandlers}>
            <ListView
              ref={ref => this.listView = ref}
              onScroll={this.handleScroll}
              dataSource={posts}
              renderRow={this.renderRow}
              renderSectionHeader={this.renderHeader}
              onEndReachedThreshold={300}
              onEndReached={this.getPosts}
              enableEmptySections={true}
              refreshControl={
                <RefreshControl
                  refreshing={refreshing}
                  onRefresh={this.onRefresh}
                />
              }
            />
            {!onProfile && this.renderSettings()}
          </View>
        }
        {this.renderComments()}
        {loading && !refreshing && <Loading />}
      </Animated.View>
componentWillMount() {
    this.listViewResponder = PanResponder.create({
      onMoveShouldSetPanResponderCapture: this.setMove,
      onPanResponderMove: this.handleMove,
      onPanResponderRelease: this.handleMoveEnd,
      onPanResponderTerminationRequest: () => false
    });
    this.scrollResponder = PanResponder.create({
      onStartShouldSetPanResponderCapture: (e) => e.nativeEvent.pageY < THUMB_SIZE,
      onPanResponderRelease: this.handlePress,
    });
  }

It's works fine on iOS,
But on Android onPanResponderRelease doesn't calls every time.

@smallpath
Copy link

Hello, on Android, onPanResponderTerminate will be called rather than onPanResponderRelease, you can add following statement to make it work

onPanResponderTerminate: this.handleMoveEnd

@mikeygee
Copy link

mikeygee commented Sep 8, 2016

I am also having an issue with Android only. In my case, I am putting pan responder handlers on a ListView. It detects my gesture starting, but if the gesture also scrolls the list view, it seems to stop responding (stops calling onPanResponderMove and also never calls onPanResponderTerminate or onPanResponderRelease). It works fine on iOS. For Android, it seems to only work on non-scrolling views.

@viix
Copy link

viix commented Sep 18, 2016

+1

@AlbertBrand
Copy link
Contributor

AlbertBrand commented Oct 4, 2016

As a workaround, I found out that you should add the panResponders to an inner view of a ScrollView. An Android listview/scrollview natively intercepts touches which kills JS touch events on the listview/scrollview and its parents but not on any children.

@shahen94
Copy link
Author

shahen94 commented Oct 5, 2016

@AlbertBrand Thank you for your feedback.
But in that case how we can render row , header, separator etc. ?

@AlbertBrand
Copy link
Contributor

AlbertBrand commented Oct 5, 2016

Sorry, my bad, my proposed solution only works for ScrollViews, not ListViews:
<ScrollView><View {...panResponder.panHandlers}>[children]</View></ScrollView>.

But I suspect that the following will work: add the panHandlers on all the inner views rendered in renderRow and renderSectionHeader. Also you should add onPanResponderTerminationRequest() => false to the panresponder to make sure you're taking over touch events. That's what you're trying to do, right?

@shahen94
Copy link
Author

@AlbertBrand Yes, That's it.
But it didn't help me.

@maboelsoud
Copy link

I'm having a similar issue here. Testing on an iPhone simulator the onPanResponderRelease calls but doesn't on my android phone. Is this not implemented on the native side?

@shahen94
Copy link
Author

@Mohamed-Abo-El-Soud It's implemented, Looks like it's fixed in this version.

@reinisseredzins
Copy link

+1

@hramos
Copy link
Contributor

hramos commented Jul 21, 2017

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.

@hramos hramos closed this as completed Jul 21, 2017
@hramos hramos added the Icebox label Jul 21, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Jul 21, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

10 participants