Giter Site home page Giter Site logo

Comments (5)

dbismut avatar dbismut commented on May 22, 2024 2

Hey @tim-soft we've just released beta of v5.0.0 ([email protected]) that introduces new gestures, including pinch.

The pinch handler returns da instead of xy (d for distance and a for angle), but you'll probably end up using local that returns delta with book-keeping, and that you should use to calculate the scale or the rotation. Here is a temp codesandbox here that does just that.

Note that there's quite a few api changes that are mentioned here. Usage for pinch should be:

const bind = useGesture({ onDrag: () => {}, onPinch: () => {} }, {...config})

Edit: bump to 5.0.0

from use-gesture.

drcmda avatar drcmda commented on May 22, 2024 1

never thought about it but would be a useful addition. do you have any ideas regarding the api that you like? i think i would trust your realworld usecase more than my whims right now, i haven't done much with multitouch before.

from use-gesture.

tim-soft avatar tim-soft commented on May 22, 2024 1

@dotlouis I haven't had much time to mess with this recently but here is the actual code that I'm using for a lightbox library

tim-soft@5bef968

Then you can use this by

<Gesture key={i} onMove={props => this.onMove({ ...props, i })}>
  {({ pinch: [, pinchScale] }) => (
    <Spring native to={{ pinchScale }}>
      {({ pinchScale }) => (
        <animated.div style={{ transform: `scale(${pinchScale})`, }}>
          <img />
        </animated.div>
      )}
    </Spring>
  )}
</Gesture>

Now that I think about it, I could probably just return the pinch delta from the lib and calculate the pinchScale on my own, not really the library's job/opinionated

demo: https://next-portfolio-rfflj3yd8.now.sh/portfolio
click any picture to open lightbox, pinch zoom the images

from use-gesture.

dotlouis avatar dotlouis commented on May 22, 2024

Actually trying to work with multi-touch events too (pinch to zoom). I will report any findings if it can help

from use-gesture.

drcmda avatar drcmda commented on May 22, 2024

@tim-soft so let's put this into 5.x?

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.