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

Swipe getures? #71

Closed
skrichten opened this issue Jul 11, 2019 · 3 comments
Closed

Swipe getures? #71

skrichten opened this issue Jul 11, 2019 · 3 comments

Comments

@skrichten
Copy link

Curious, why are there are no handlers for basic swipe gestures?

@dbismut
Copy link
Collaborator

dbismut commented Jul 12, 2019

Hey @skrichten, good question thank you! Actually it’s pretty easy to handle swipes in all directions from the onDrag handler, using last and vxvy which gives velocity per axis.

So horizontal swipes could be handled like so:

useGesture({
  onDrag: ({ vxvy: [vx], last }) => {
    if(last && vx < 0.3) {
         // swipeLeft
    }
    else if (last && vx > 0.3) {
      // swipeRight
    }
  }
)}

I've made a small carousel utility that uses swipe, you can see the related bit of code here.

I'll add a codesandbox example for swipe though, it is indeed an important feature.

@skrichten
Copy link
Author

Cool, thanks for the examples!

@dbismut dbismut closed this as completed Jul 12, 2019
@dbismut
Copy link
Collaborator

dbismut commented Jul 13, 2019

For reference, here is a working example that was added to the readme: https://codesandbox.io/s/crimson-dawn-pzf9t

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

No branches or pull requests

2 participants