Change Pinch Gesture Handler Behavior to transition to END state after one finger is taken off screen and one left
See original GitHub issueDescription
After testing PinchGestureHandler in react-native-gallery-toolkit I found that on the real device Pinch gesture is active even though we have only a single finger on the screen. This breaks my focal point logic which is working as expected on Android.
Screenshots
As soon as I release one finger - it jumps because now the focal point is not the point between fingers, but that single finger location.
But it should just transition to state “END” instead.
Steps To Reproduce
- Run pinch example
- Add log to onGestureEvent of PinchHandler
onGestureEvent={(evt) => console.log(evt.nativeEvent.numberOfFingers)}
- Do the pinch then release one finger and move it
- See that it fires even with 1 finger pressed after wi
Expected behavior
The gesture should be in the state “end” as soon as the user releases one finger – just like on Android
Actual behavior
The gesture remains active even when the user released one finger
Snack or minimal code example
Run the example app
Package versions
- React: 16.13.1
- React Native: 0.63.3
- React Native Gesture Handler: 1.8.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Change Pinch Gesture Handler Behavior to transition to END ...
Change Pinch Gesture Handler Behavior to transition to END state after one finger is taken off screen and one left.
Read more >Pinch gesture | React Native Gesture Handler
The gesture activates when fingers are placed on the screen and change their position. Gesture callback can be used for continuous tracking of...
Read more >Handling pinch gestures | Apple Developer Documentation
A pinch gesture recognizer enters the UIGestureRecognizer.State.began state only after the distance between the two fingers changes for the first time.
Read more >React Native Gesture Handler: Swipe, long-press, and more
Implementing gestures in a React Native app improves the user experience. Learn how to create swipeable, pan, long-press, and other ...
Read more >Gestures
The map will keep moving with a little momentum after the finger was lifted. ... you can always combine the gesture handling available...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@terrysahaidak please consider the opposite as currently smooth 1->2->1->2 finger movement on iOS seems to function better than Android. I have just spent a good amount of time on this issue and can give a bit more insight after looking at the Android implementation. Currently Android gets a start event with 1 finger pressing, this start event is missing info for focal, etc. Then until a second finger is applied no active events are fired, once a second finger is applied active events come in again until less than 2 fingers remain, GestureHandler then fires the end event, but as a finger still remains I believe MotionEvents from ScaleGestureDetector still arrive and are discarded. This means that at best with a Pan and Pinch Handler on Android you can pan, then pinch, then pan, i.e. 1->2->1 fingers. You cannot return to 2 finger use. I have implemented this using reanimated 2 alongside the iOS version where the pinch handler takes over indefinitely after it starts and it seems to me as the pinch handler on iOS is almost a pass through to
UIPinchGestureRecognizer
it is the preferable way; but either way matching the interaction would be the key preference here.@iqqmuT You can take a look at my implementation of pinch to zoom here: https://github.com/GetStream/stream-chat-react-native/blob/92f891e42ec2c881d357ffc1a759fc8c26edf727/src/components/ImageGallery/ImageGallery.tsx . Overall for a smooth experience the iOS functionality makes more sense and is a 1:1 representation of the native handler as I noted previously. You can easily deal with the change in the number of touches detected, but with Android ending the gesture tracking you are not given a choice of how you want to deal with one finger being removed. Therefore the iOS implementation adds flexibility and utility.