question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't cleanly pass touch/click events to panzoom children

See original GitHub issue

Describe the bug

On latest devices, e.g. desktop Chrome or iOS Safari on iPhone X, click events to the panzoom element are still passed down to children, and we can add “isZooming” detection code using the panzoom events to determine if we want to handle the click events or not, and everything’s great.

Unfortuantely, in older devices, e.g. iPhone SE iOS v12.4 on Safari, I’m seeing the click events are eaten by event.preventDefault(). This can be avoided using the excludeClass, however we have so many clickable children that it breaks the pinch/zoom behavior more often than not.

I’m not quite sure what pattern to use when handling many clickable children, or if there’s a different library that makes more sense for our use-case.

Your environment

  • Version of panzoom 4.1.x
  • Browser and browser version Various

Expected behavior

Pinching to zoom doesn’t click child elements and doesn’t behave differently if child elements are under part of the gesture.

Clicking on child elements should trigger their click events.

Actual behavior

Pinching to zoom behaves erratically with excludeChildren on since there are so many clickable elements.

Child elements are unfortunately only clickable with this enabled on older devices.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
timmywilcommented, Apr 8, 2020

Thanks for opening an issue. I don’t think it’s possible to pass the events back down to children in any clean way. The event has already propagated from the children as events bubble up by nature. However, your first instinct of binding to the same event as panzoom is probably the right way to go. But instead of copying that block, I could expose that events variable and then you can use event.stopImmediatePropagation.

0reactions
timmywilcommented, Jul 7, 2020

🎉 This issue has been resolved in version 4.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

PanZoom catch Touch Up event - Stack Overflow
I'd prefer that panzoom would optionally pass click-like events down as clicks to its children, perhaps? I could try creating a PR around ......
Read more >
@bpagoagadev/panzoom - npm
The library will handle ontouch events very aggressively, it will preventDefault , and stopPropagation for the touch events inside container.
Read more >
Keyboard Control - mpv.io
mpv has a fully configurable, command-driven control layer which allows you to control mpv using keyboard, mouse, or remote control (there is no...
Read more >
Panzoom
Panning and focal-point zooming (shift + mousewheel). // This example also showcases the canvas option // Pointer events anywhere in the parent move...
Read more >
Manage touch events in a ViewGroup - Android Developers
On this page · Intercept touch events in a ViewGroup. Process ACTION_OUTSIDE events · Use ViewConfiguration constants · Extend a child view's ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found