question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Detecting touch taps and double taps while using react-draggable

See original GitHub issue

I’m using this great library to add dragging functionality to components and it works great. However, I have the following issue:

  • Before I was using this library, I could capture the standard click and double click events and they would work for both mouse and touch devices domNode.addEventListener('click', (event) => {}); domNode.addEventListener('dblclick', (event) => {});

  • But now that I’m using this library, the click and dblclick events are only being triggered for mouse inputs, but not for touch devices, how can I detect touch taps and double taps while using this library?

thank you 😃

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
asile12commented, Oct 20, 2021

if someone is looking for a temporary fix, I managed to make it work with this

<Draggable {...dragHandlers} >
  <div 
    id={props.id} 
    ref={myRef} 
    onClick={clickedMe} 
    onTouchEnd={clickedMe}  // <-- this
    etc...
0reactions
sachinksachucommented, Feb 17, 2022

I also faced this issue, touch was not working in mobile screen. so I added onTouchStart attribute to call the function onTouchStart={()=> clickedMe()} Got the solution from : https://github.com/react-grid-layout/react-draggable/issues/550

Read more comments on GitHub >

github_iconTop Results From Across the Web

Detect Multiple Touches in React Native with the Gesture ...
In this video you'll be introduced to React Native's Gesture Responder System by creating a component to detect n number of presses.
Read more >
React Native Gesture Handler: Swipe, long-press, and more
With TapGestureHandler , we can implement both single- and double-tap gestures. Let's start with single-tap gesture and then move on to a double ......
Read more >
Taps, drags, and other gestures - Flutter documentation
This document explains how to listen for, and respond to, gestures in Flutter. Examples of gestures include taps, drags, and scaling. The gesture...
Read more >
How do you detect a double tap drag? - Stack Overflow
You can use GestureDetector.OnDoubleTapListener to detect the double tap gesture and trigger a flag. Then on your onTouch (MotionEvent.
Read more >
Gesture options - @use-gesture documentation
tapsThreshold, drag, Customize the displacement triggering taps when using the ... If true , drag and pinch will use touch events on touch-enabled...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found