software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
6.07k stars 975 forks source link

Double tap don't works anymore with only one finger (now requires at least two fingers) #1213

Closed philvoyer closed 3 years ago

philvoyer commented 3 years ago

Description

The TapGestureHandler seems to have a bug with multitap.

It is now impossible to do a double tap with only one finger, it now requires two fingers to be detected.

Steps To Reproduce

  1. Open the multitap demo from Example project.
  2. Try to do a double tap (it won't works, considered as a single tap).
  3. Try to do the second tap with a new finger (it will works and it is detected at the average position between the two fingers).

Expected behavior

Double tap with only one finger.

Actual behavior

Double tap is only possible with two fingers.

Snack or minimal code example

Can be reproduce in the react-native-gesture-handler demo :

https://snack.expo.io/@adamgrzybowski/react-native-gesture-handler-demo

philvoyer commented 3 years ago

Does anyone have a similar problem, of a minimalist example of a working double tap gesture ?

dev-ltk commented 3 years ago

I got the same problem.

I have two scrollviews nested under a pageviewer. Two scrollviews are almost identical except the image attached to the scrollview are different. I use double to enlarge the image to the location where users tap. A few days ago, it worked completely fine. While I revisited the code and do some modifications today, it completely failed.

I move back to the first step and try the simple code in the documentation. It works at first. Once I swipe to another scrollview and move back to the first scrollview, it can only detect single tap. Magically, the second scrollview works completely fine with double tap. If I restart expo client and reload the app, it seems to work at first and the same problem appears again after I swipe to other scrollviews.

I also tried a long list of scrollviews. The double tap only works on the last scrollviews.

Tried on both iphone and ipad, same problem happened.

philvoyer commented 3 years ago

A workaround can be to compare the a time threshold between 2 single taps.. but it defeats the purpose of using this library for double tap gestures.

Does anyone have similar problem or a solution ?

dev-ltk commented 3 years ago

I finally make my code work. I use hook in create reference. I wrap TapGestureHandler in a PageViewer. Instead of one single reference, I need an array of references, each assigns to one single page. The following is my code.

// page is my variable
const doubleTapRef: any = useRef(page.map(() => createRef()));
...
<TapGestureHandler
    waitFor={doubleTapRef.current[index]}>
    <TapGestureHandler
         ref={doubleTapRef.current[index]}>
...
    </TapGestureHandler>
</TapGestureHandler>
philvoyer commented 3 years ago

For your information, the problem disappears after upgrading to expo SDK40, which has the side effect of upgrading react-native-gesture-handler from 1.6.0 to 1.8.0.

solominh commented 3 years ago

react-native-gesture-handler: v1.10.0 Project examples are not working on iOS devices (just tested on iOS simulator) and not working on Snack as well Double tap not working => always activate single tap

react-native-gesture-handler: v1.10.3 => double tap working

pihomeserver commented 2 years ago

Upgraded with 1.10.3 and still get the issue. The official demo randomly works with 2 fingers, not at all with one (on iPad)

pihomeserver commented 2 years ago

"Funny" fact : If i don't set minPointers prop then i need 2 fingers to trigger the handler (default value seems to be 1 based on documentation) If i set minPointers prop to 1 then i still need 2 fingers to trigger the handler If i set minPointers prop to 2 then i need 3 fingers to trigger the handler If i set minPointers prop to 3 then i need 4 fingers to trigger the handler (that's a little bit difficult to double 4-fingers tap)