react-easy-panzoom icon indicating copy to clipboard operation
react-easy-panzoom copied to clipboard

Glitchy zoom and pan on mobile devices

Open davwheat opened this issue 4 years ago • 5 comments

Video attached.

Panning often scrolls up and down the page instead of panning.

Zooming is very laggy, random or doesn't work at all.

https://puu.sh/ED3Ps/d38a0c1a8d.mp4

davwheat avatar Nov 10 '19 22:11 davwheat

Even worse in iPhone devices.

You will have to hijack the touch events:

if (/iPad|iPhone|iPod/.test(navigator.userAgent)) {
  window.addEventListener(
    "touchstart",
    ev => {
      ev.preventDefault();
    },
    { passive: false }
  );
}

n1ru4l avatar Nov 11 '19 08:11 n1ru4l

The only issue is that it doesn't solve the issue.

It just prevents scrolling the whole page!

davwheat avatar Nov 11 '19 16:11 davwheat

I mainly solved this by adding a class to the <PanZoom ... /> element with these styles. This has prevented scrolling and significantly improved performance! I would highly recommend including info about this in the documentation.

.panZoom,
.panZoom * {
  touch-action: none;
}

davwheat avatar Nov 11 '19 19:11 davwheat

@davwheat since now I haven't focused that much on the mobile side of this library. What you are saying is relevant and will consider including it in a new version.

mnogueron avatar Nov 12 '19 07:11 mnogueron

The only issue is that it doesn't solve the issue.

It just prevents scrolling the whole page!

You have to only apply it when scrolling is in progress (for iOS)... 🙂

n1ru4l avatar Nov 12 '19 07:11 n1ru4l