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.onStartShouldSetPanResponder reports 1 single touch on multi touch gestures #30479

Closed
darron1217 opened this issue Nov 26, 2020 · 1 comment

Comments

@darron1217
Copy link

darron1217 commented Nov 26, 2020

From #17928

Description

This bug still exists in latest version 0.63.3 on Android.
View's onStartShouldSetResponder works well.
But PanResponder's onStartShouldSetPanResponder works strangely.

React Native version:

System:
    OS: macOS 10.15.7
    CPU: (4) x64 Intel(R) Core(TM) i5-4690 CPU @ 3.50GHz
    Memory: 49.67 MB / 24.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.18.3 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.8 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.6, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6626763
    Xcode: 11.6/11E708 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.8 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.3 => 0.63.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

If I touch the screen with two fingers, I get two events using View.onTouchStart, but only one invocation on a PanResponder's onStartShouldSetPanResponder callback (since I guess it aggregates those events). However, the number of reported touches is always just 1. There is simply no way to determine whether my PanResponder should actually handle a given touch event based on the supplied gesture information, as it's lacking the aggregated context. I assume that is not the desired behavior...

My use case: A view with a PanResponder within a FlatList. Depending on whether this is a pinch gesture or just a swipe, I need to grab the gesture or not in order to have the FlatList handle it.

Expected Results

On multi-touch gestures (e.g. two fingers touching the screen at the same time), the event and gestureState that are submitted to onStartShouldSetPanResponder should contain all active touches, not just one.

Snack, code example, screenshot, or link to a repository:

(Edit) I created snack
https://snack.expo.io/@darron1217/panresponder-multitouch

Create an app, run it locally with a PanResponder like this. You'll get three times "1":

this.myResponder= PanResponder.create({
        onStartShouldSetPanResponder: (evt, gestureState) =>  {
            alert("active touches: " + gestureState.numberActiveTouches + ", evt touches: " + evt.nativeEvent.touches.length + ", " + evt.nativeEvent.changedTouches.length);
            return true,
@darron1217
Copy link
Author

returing true on onStart* made touches length to 1.
It was not the problem of PanResponder

@facebook facebook locked as resolved and limited conversation to collaborators Nov 28, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Nov 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants