-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conflict when listening for both pinch and twofingerpan #6
Comments
Thanks for reporting the issue and thank you for providing code. It should be possible to simultaneously use I am not yet exactly sure yet what happens in your case. I understand it as follows:
I this is the case, I assume that Important: Should the user be able to to first |
For illustration I created images for two input scenarios. Scenario 1: Pinch while Twofingerpan
Scenario 2: Twofingerpan - Pinch - Twofingerpan, fingers never removed
Is the described the expected behaviour? |
Hi there, thanks for your swift reply, as for your questions:
A and B are correct. C isn't the case, pinching does work and so does panning. It's just that they don't trigger entirely according to expectation. If I interpret your illustration and vectors correctly you are describing the expected behaviour. Just for the sake of clarity, I have created a codepen to illustrate the example. I have simplified the code I added above a little. I'm using Vue in the example, but the bulk of the logic is in the At certain times, the touch listeners behave very well, but at others the issue becomes apparent, for instance when executing what feels like an obvious pinch which then actually triggers a doublepan. At others, the other way around. Sometimes both happen at the same time (for instance doublepan in a small circular motion would both expand/shrink the image during pan). I have reproduced this on both Pixel 3 (Chrome on Android) and iPad Air (Safari) |
I implemented the possibility to block gestures in the latest build for testing, see docs. However, scenario 2 as illustrated above will not work this way yet. Example:
If you want to perform a pinch after a twofingerpan without removing the fingers from the surface WITHOUT allowing both pinch and twofingerpan at the same tine, twofingerpan has to be invalidated on the fly before a pinch can be recognized. I am still thinking about the best way to implement this case. I made a few tests and got a lot of "twofingerpanstart" and "twofingerpanend" events. Although this reflected the input I did with my fingers, I am not sure yet if this is the best way to do it. I also played around with your codepen. I can reproduce what you described when moving both fingers in "parallel circles". I could not reproduce a twofingerpan that felt like a pinch except when being on MAX_ZOOM or MIN_ZOOM. When I maxed out the zoom level and do a pinch, the pinch gets intentionally ignored and the picture moves a little according to the pan input I unintentionally make. Finally, I found out that twofingerpan gets triggered if I only move one finger and keep the other one on the same spot, which I think is not what users are accustomed to. I will restrict twofingerpan to a parallel movement of 2 fingers. |
Verified the
This doesn't sound necessarily like a problem because the fingers used for pinching and two finger panning tend to be different (though I understand when comparing the pointer vectors, the exact fingers representing the pointers don't matter). As far as I'm concerned the original issue has been resolved, feel free to close this issue (not sure if you want to treat the issue quoted above in the scope of this issue, or handle it separetely, if at all). |
Question about the block functionality. |
This is scenario 2, as illustrated above. The current block interface only affects scenario 1, where two gestures are simultaneously performed (if I recall it correctly).
There is a setting for the
Which states, that there is a (initial) 5 pixel tolerance before a pinch is being recognized, resulting in a This means the following: the user touches the surface with two fingers. Those fingers have an initial distance between each other. When this distance changes more than 5 pixels, this is interpreted as a pinch. After that, pinch becomes active, and all changes in distance will fire the pinch event. If this setting is too sensitive, you can adjust it. This is an advanced setting which might result in strange behaviors, but I should cover this in the documentation. |
Hi there,
first of all fantastic work on the library as its a nice up-to-date variant of a certain popular library.
While I find the implementation of pinch much more accurate than HammerJS provides, I struggle to combine a
pinch
andtwofingerpan
listener on the same element. Basically the pan handler is conflicting with the pinch making it impossible to zoom, or vice versa. In HammerJS there was the concept ofrecognizeWith
which would give a PointerListener awareness of the other basically managing their priorities.Is there something similar available or is my approach a little too naive ? My current code is:
Attaching either the
pinch
ortwofingerpan
listeners separately from each other works fine, when adding them both,twofingerpan
becomes dominant.The text was updated successfully, but these errors were encountered: