-
Notifications
You must be signed in to change notification settings - Fork 301
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
Pinch gestures trigger onWheel #80
Comments
Right, I think see where this comes from. Can you confirm you’re using a trackpad with Chrome or if using Safari, are your binding the component (ie not using domTarget)? Essentially when you pinch to zoom on a trackpad browsers might send the onWheel event with the ctrl modifier key flag set to true. I’ll write a fix asap. A temp fix would be to check if the ctrlKey flag is set to true in your life onWheel handler. |
I'm using the touchpad of my Dell XPS 15 with Windows 10 in Firefox. |
@andreas-eberle I've released
Regarding the first point, the pinch-zoom on a trackpad should be default prevented, to avoid the wheel event propagating to the window. If you attach the handlers directly in React, non-passive events aren't supported, therefore Note that there's a few breaking changes in |
@dbismut: I tried out version My code looks like this:
and when I pinch, I get the following output in the console:
Am I doing something wrong? Or is there still an issue in the library? |
That's really weird, here is the code in the WheelRecognizer: if (event.ctrlKey && this.controller.actions.has('onPinch')) return Would you be able to set a simple repro sandbox somewhere? Here is a csb where the left square reacts to wheel, and the right square should react to pinch. Do both square update on pinch on your end? |
If you change the code of the callbacks in your sandbox to:
You can see in the console that |
Hm indeed my code is a bit dumb since I’m not showing the same offset index 😅 I’m on my phone and will only be able to check that back later tonight. Can you confirm this is also happening on Chrome? does this (both gesture logging in the console) also happen when you wheel while physically pressing the ctrl key? |
|
There must have been an issue when I published on npm. Please try |
No worries! Thanks for the support and super fast help! It works now 👍 |
@dbismut I have version 7.0.5 and this property is not available, also it says also how do you know if it is a zoom-in pinch or a zoom-out pinch? |
@tommedema the capture shows that the gesture is no longer active so this is not surprising that pinching is false. Zoom in means that the movement displacement between your fingers has increased. So |
I try to use your component to zoom an image in a canvas by scrolling as well as by pinching. Therefore I use
useGesture
to addonWheel
andonPinch
listeners. However, when I pinch, both callbacks are called.So I tried to only use the onWheel callback. It is enough to zoom my canvas whenever the user scrolls or pinches. However, since pinching gives way less onWheel events as the actual scrolling, I end up with a way slower zooming when I use pinching.
So I have three questions:
Many thanks in advance!
The text was updated successfully, but these errors were encountered: