-
-
Notifications
You must be signed in to change notification settings - Fork 981
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
Tap gesture with multiple pointers fail to start on 2.15.0
#2754
Comments
I'm in the process of looking through the diff between |
2.15.0
2.15.0
Adding const tap = Gesture.Tap()
.minPointers(2)
.runOnJS(true)
.onBegin((event) => {
setLog((prev) => [`onBegin: ${JSON.stringify({ event })}`, ...prev]);
})
.onStart((event) => {
setLog((prev) => [`onStart: ${JSON.stringify({ event })}`, ...prev]);
})
.onEnd((event, success) => {
setLog((prev) => [
`onEnd: ${JSON.stringify({ event, success })}`,
...prev,
]);
})
.onFinalize((event, success) => {
setLog((prev) => [
`onFinalize: ${JSON.stringify({ event, success })}`,
...prev,
]);
}); |
Looks like theres a bit of a diff in the tap handler for macOS support, is suepct it's something there but haven't found the smoking gun yet. 👀 |
Hi @levibuzolic! I will take a look at it and get back to you as soon as I find something! |
Okay, I've found out what causes this problem. Before macOS support We will prepare a PR to fix that soon! |
@m-bert awesome, thanks for looking into this! 🙇♂️ |
I've prepared PR that should fix this problem and I'd be happy if you could check if it helps! |
## Description In 2.15.0 we released partial support for macOS. In `Tap` and `Rotation`, instead of passing original `touches` parameter to keep iOS behavior, we changed that to `NSSet` with `event` object. This means that instead of having multiple `UITouch` objects in that set, we only had one object which cumulates all touches. Because we use `[touches count]` to find number of touches, change mentioned above resulted in obtaining wrong values. Fixes #2754 ## Test plan <details> <summary> Tested on code from #2754 </summary> ```jsx import React, { useState } from 'react'; import { Text, StyleSheet, View, ScrollView, Button } from 'react-native'; import { GestureDetector, Gesture } from 'react-native-gesture-handler'; export default function Home() { const [log, setLog] = useState<string[]>([]); const tap = Gesture.Tap() .minPointers(2) .runOnJS(true) .onBegin((event) => { console.log('onBegin', JSON.stringify({ event })); setLog((prev) => [`onBegin: ${JSON.stringify({ event })}`, ...prev]); }) .onStart((event) => { console.log('onStart', JSON.stringify({ event })); setLog((prev) => [`onStart: ${JSON.stringify({ event })}`, ...prev]); }) .onFinalize((event, success) => { console.log('onFinalize', { event, success }); setLog((prev) => [ `onEnd: ${JSON.stringify({ event })}; success:${success}`, ...prev, ]); }); return ( <View style={styles.container}> <Button title="Reset" onPress={() => setLog([])} /> <GestureDetector gesture={tap}> <View style={styles.container}> {/* <ScrollView> */} {log.map((line, i) => ( <Text key={i} style={[styles.log, i === 0 && styles.logNew]}> {line} </Text> ))} {/* </ScrollView> */} </View> </GestureDetector> </View> ); } const styles = StyleSheet.create({ container: { width: '100%', height: '100%', backgroundColor: 'white', }, log: { fontSize: 12, color: 'grey', padding: 5, }, logNew: { backgroundColor: '#e6ffec', color: 'black', }, }); ``` </details>
Description
Upgrading from
2.14.1
to2.15.0
has stopped tap gestures withminPointers(2)
from firing.The tap gesture is setup as following:
2.15.0
onlyonBegin
fires, no other event is triggered.2.14.1
all 3 events are triggered as expected.minPointers(1)
, the gesture works as expectedMinimal reproduction
https://github.com/levibuzolic/react-native-gesture-handler/blob/main/example/src/new_api/twoPointerTap/index.tsx
Video
Kapture.2024-02-09.at.17.07.38.mp4
Steps to reproduce
Gesture.Tap()
with.minPointers(2)
onStart
andonEnd
are not firedSnack or a link to a repository
https://github.com/software-mansion/react-native-gesture-handler
See the
TwoPointerTap
example.Gesture Handler version
2.15.0
React Native version
0.72.0
Platforms
iOS
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
Paper (Old Architecture)
Build type
Debug mode
Device
iOS simulator
Device model
No response
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: