use-gesture icon indicating copy to clipboard operation
use-gesture copied to clipboard

Add tap, long tap and double tap gesture

Open jrmi opened this issue 4 years ago • 18 comments

Although this 3 gestures can already be done with current existing one, proper hooks can ease the job and have consistent implementation.

Information:

  • React Use Gesture version: [v8.1.0-beta.6]

jrmi avatar Nov 30 '20 21:11 jrmi

Once 8.1.0 is released I can consider a pull request to implement this.

dbismut avatar Dec 02 '20 11:12 dbismut

+1

Raaghu avatar Jan 01 '21 09:01 Raaghu

Note that onDblClick and onClick handlers exist in React + this lib has a tap state attribute and a delay config option.

All in all I guess this makes detection of any of these gestures trivial IMO.

dbismut avatar Jan 01 '21 09:01 dbismut

I created a useDoubleClick hook for a project for this very reason, since onDblClick will still fire your onClick handler. Really simple code https://github.com/tim-soft/use-double-click

tim-soft avatar Feb 13 '21 02:02 tim-soft

+1 Would love a double tap as well!

serewaste avatar Mar 04 '21 06:03 serewaste

I don't think I'll handle this myself. If someone wants to give it a shot please open a PR.

dbismut avatar Mar 04 '21 07:03 dbismut

+1 Would love a double tap as well!

mindyourlifeguide avatar May 18 '21 08:05 mindyourlifeguide

Is there any way to temporarily implement this function? I am worried that other click/double click components will conflict with @use-gesture.

StringKe avatar Sep 08 '21 01:09 StringKe

yeah I have that problem, added my own long press handler but now useDrag 's down variable is getting stuck on true, so dragging happens after long press even without clicking again

laclance avatar Sep 29 '21 12:09 laclance

@laclance would you mind elaborating a bit more and possibly submit a sandbox?

dbismut avatar Sep 29 '21 14:09 dbismut

So the problem is if you press or hold after swiping then a swipe will always get triggered at the same time. This was not the case until I upgraded from react-use-gesture.

https://codesandbox.io/s/laughing-einstein-23kd2

laclance avatar Sep 30 '21 08:09 laclance

@laclance thanks for the sandbox. Can you describe what you're trying to achieve feature-wise? The code seems a bit complex at first glance.

dbismut avatar Sep 30 '21 08:09 dbismut

sorry I tried to remove as much code as I could, so basically our app has many objects that have different functionality when pressed, held or swiped (e.g select, edit, delete, respectively, with animations) and also switch screens by swiping when on mobile.

laclance avatar Sep 30 '21 08:09 laclance

it's been a while since I created the hooks but I believe most of the complexity came about when trying to get the events working on multiple objects, for example when the container and child components all need press, hold and swipe events.

laclance avatar Sep 30 '21 08:09 laclance

@laclance Have a look at this https://codesandbox.io/s/great-tu-kzc8m?file=/src/App.tsx

dbismut avatar Sep 30 '21 14:09 dbismut

thank you, I ended up just implemented everything myself, wasn't to difficult but that might be helpful if I need more animations.

laclance avatar Oct 05 '21 07:10 laclance