Skip to content
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

Add tap, long tap and double tap gesture #241

Open
jrmi opened this issue Nov 30, 2020 · 16 comments
Open

Add tap, long tap and double tap gesture #241

jrmi opened this issue Nov 30, 2020 · 16 comments
Assignees

Comments

@jrmi
Copy link

jrmi commented Nov 30, 2020

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]
@dbismut
Copy link
Collaborator

dbismut commented Dec 2, 2020

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

@Raaghu
Copy link

Raaghu commented Jan 1, 2021

+1

@dbismut
Copy link
Collaborator

dbismut commented Jan 1, 2021

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.

@tim-soft
Copy link
Contributor

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

@serewaste
Copy link

+1 Would love a double tap as well!

@dbismut
Copy link
Collaborator

dbismut commented Mar 4, 2021

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

@mindyourlifeguide
Copy link

+1 Would love a double tap as well!

@StringKe
Copy link
Contributor

StringKe commented Sep 8, 2021

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

@laclance
Copy link

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

@dbismut
Copy link
Collaborator

dbismut commented Sep 29, 2021

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

@laclance
Copy link

laclance commented Sep 30, 2021

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

@dbismut
Copy link
Collaborator

dbismut commented Sep 30, 2021

@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.

@laclance
Copy link

laclance commented Sep 30, 2021

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
Copy link

laclance commented Sep 30, 2021

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.

@dbismut
Copy link
Collaborator

dbismut commented Sep 30, 2021

@laclance
Copy link

laclance commented Oct 5, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants