Comments (5)
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.
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.
@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
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.
Actually trying to work with multi-touch events too (pinch to zoom). I will report any findings if it can help
from use-gesture.
@tim-soft so let's put this into 5.x?
from use-gesture.
Related Issues (20)
- Pinch bug: after opening/closing context menu, pinching gesture can be fired with 1 finger HOT 1
- Delegate drag to remaining finger after pinch or support multi-finger drag HOT 5
- Using modifierKey causes the mac pinch event to return HOT 2
- Using pointer.touch cannot be dragged under windows system HOT 6
- useDrag breaks onClick listener in React portal to shadow dom HOT 2
- using video element inside useDrag component doesn't allow the video to play/pause using single click over the video HOT 6
- DragBounds ignored when rerender target HOT 1
- dynamically updating useDrags axis option resets movement : [mx,my] HOT 2
- Using alt+left for navigation prevents all gestures on elements with axis: 'y'
- Drag gesture: Delay setting behavior does not adhere to documentation HOT 4
- Drag + Click + filtertaps option breaks onclick listener. Drag + Click + Treshold works. HOT 1
- touch-action: pan-y prevents L shaped gestures to scroll
- onPinch breaking on control + scroll HOT 5
- Where do I import a3f from? HOT 1
- Getting the error "a3f is not defined"
- Textarea doesn't work inside gesture container HOT 4
- Documentation website is broken (in firefox) HOT 8
- Type error with @types/react >=18.2.66
- (Firefox) Click event fired on drag end
- 100ms delay between pointermove events in Android webviews? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from use-gesture.