dimsemenov / PhotoSwipe

JavaScript image gallery for mobile and desktop, modular, framework independent
http://photoswipe.com
MIT License
24.18k stars 3.31k forks source link

Chrome iOS can cause zoom with one finger #2068

Open bakura10 opened 1 year ago

bakura10 commented 1 year ago

Hi,

We had a user of one of our theme (which relies on PhotoSwipe for zooming) a strange issue that happens exclusively on Chrome iOS (Safari does not exhibit the issue).

It is a bit complex to explain, so I will attach a video, but to reproduce the issue you have to:

  1. Open the zoom.
  2. Maintain a long tap on the image to show contextual menu.
  3. Close the contextual menu.
  4. Move your finger.

Instead of moving the image, it will actually zoom. This is also reproducible on the library demo.

https://github.com/dimsemenov/PhotoSwipe/assets/1198915/abaa36ff-dbc9-4f7e-b9ab-9fca5564561d

Thanks :)

dimsemenov commented 1 year ago

Odd issue, I'll look into it. It's possible to disable the context menu by calling preventDefault on pointerdown, but that's not ideal.

bakura10 commented 1 year ago

Thanks a lot for investigating this issue :)

dimsemenov commented 1 year ago

Fought with this for half of a day. It seems in the new iOS Chrome update neither pointerup nor pointercancel is called when the context menu disappears. Pointer-capture also doesn't help, and lostpointercapture event never fires.

The Firefox on IOS does seem to work correctly.

I'm not sure yet what to do, as the only thing that helps is disabling the context menu via something like:

lightbox.on('bindEvents', () => {
  lightbox.pswp.scrollWrap.ontouchstart = (e) => e.preventDefault();
});

The other thing that helps also is switching from pointer events back to old touch events API. With touch events touchend does fire right before the next touchstart.

bakura10 commented 1 year ago

Thanks for spending time on this. We should open a bug tracker to Chrome. I think you have more context about the issue than I have, can you please try to open one ? Otherwise I will try to do it myself :)