Skip to content

Detecting Multi-touch Gestures #295

Answered by dbismut
Johannes5 asked this question in Q&A
Discussion options

You must be logged in to vote

v10 should make it more reliable for that kind of stuff, but no it's not built-in.
You can try this in v9 though and see if it works.

const fourFingersTimeStamp = React.useRef(0)
const bind = useDrag(({ touches, swipe, timeStamp }) => {
  if (touches === 4) fourFingersTimeStamp.current = timeStamp
  if (swipe[1] && timeStamp - fourFingersTimeStamp.current < 50) alert('4 FINGERS SWIPE')
})

Swipe is detected based on velocity, distance and duration of the first finger that pressed the screen. The code above should work if at one point of the gesture, four fingers were pressing the screen and between the time the gesture ends and the last time 4 fingers were pressing the screen, there was a …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Johannes5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants