GithubHelp home page GithubHelp logo

Swipe getures? about use-gesture HOT 3 CLOSED

skrichten avatar skrichten commented on August 21, 2024
Swipe getures?

from use-gesture.

Comments (3)

dbismut avatar dbismut commented on August 21, 2024 10

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.

from use-gesture.

skrichten avatar skrichten commented on August 21, 2024

Cool, thanks for the examples!

from use-gesture.

dbismut avatar dbismut commented on August 21, 2024

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

from use-gesture.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.