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 is not working when there are multiple touches #8094

Closed
faisalil opened this issue Jun 13, 2016 · 6 comments
Closed

PanResponder is not working when there are multiple touches #8094

faisalil opened this issue Jun 13, 2016 · 6 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@faisalil
Copy link

Hey,

I am trying to implement a pinch gesture and I am trying to use PanResponder for that. However, looks like there is a bug, when I have a single touch, I get all events (start, move, end) and it working well. However, when I do a 2 figures, i only get a start event a directly after a terminated event. Any pointers to what might be going wrong?

Faisal

@allthetime
Copy link

I've implemented zooming with PanResponder without issue.

The supplied argument gestureState is relatively useless for this case as it doesn't return useful data (except for the number of touches)

You have to use evt.touchHistory.touchBank which is an array of all the touches.

I'll just show you the shell of my PanResponder creator (removed all specifics)

this._panResponder = PanResponder.create({
  onStartShouldSetPanResponder: (evt, gestureState) => true,
  onStartShouldSetPanResponderCapture: (evt, gestureState) => true,
  onMoveShouldSetPanResponder: (evt, gestureState) => true,
  onMoveShouldSetPanResponderCapture: (evt, gestureState) => true,

  onPanResponderGrant: (evt, gestureState) => {
 // do stuff on start
  },
  onPanResponderMove: (evt, gestureState) => {
 // do stuff on move
//
//   THIS IS WHERE YOU USE evt.touchHistory.touchBank
//
  },
  onPanResponderTerminationRequest: (evt, gestureState) => true,
  onPanResponderRelease: (evt, gestureState) => {
  },
  onPanResponderTerminate: (evt, gestureState) => {
  },
  onShouldBlockNativeResponder: (evt, gestureState) => {
    return true;
  },
});

@mkonicek
Copy link
Contributor

@facebook-github-bot answered

@facebook-github-bot
Copy link
Contributor

Closing this issue as @mkonicek says the question asked has been answered. Please help us by asking questions on StackOverflow. StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only.

@facebook-github-bot facebook-github-bot added the Ran Commands One of our bots successfully processed a command. label Oct 27, 2016
@slorber
Copy link
Contributor

slorber commented Jul 10, 2017

@allthetime what's the difference between touchBank and evt.nativeEvent.touches ?

Also, for me it's not working very well because when I put a 2nd finger on the element, no more onPanResponderMove event is triggered unfortunatly. Any idea?

I'm trying to implement solution of https://stackoverflow.com/a/37449923/82609

@mileung
Copy link

mileung commented Mar 18, 2018

Seems like touches and multiple touches can only act on one element. I have two elements and each should have their own PanResponder, but when I have multiple touches, only the first onPanResponderMove gets called.

@uditalias
Copy link

uditalias commented Jul 11, 2018

@faisalil is your PanResponder inside a Modal?

@facebook facebook locked as resolved and limited conversation to collaborators Jul 19, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

8 participants