ironexdev / zoom

Lightweight (8 Kb) ES5 javascript plugin without any dependencies, compatible with desktop and mobile devices.
https://zoom.by-ironex.com
Apache License 2.0
33 stars 13 forks source link

`document` event listeners break mobile pages scroll #7

Open andreagobetti opened 2 years ago

andreagobetti commented 2 years ago

I noticed that there are two types of listeners, some are set on document, by using document.addEventListener(..., others are set on the elements to bee zoomed, by using massAddEventListener($zoom....

While this makes the zooming work, I noticed that after calling zoom it breaks other scrolls in my web pages, since probably the document listeners "intercept" the event and prevent it to be used to scroll.

I think I've fixed this by setting all the event listeners using massAddEventListener($zoom... instead of document.addEventListener(..., which of course is not the same, but the zoom still works and I no longer have problems related to scrolling on mobile.

If the listener on document are considered important maybe this behaviour could be managed via a setting value?

SandyMoresoda commented 2 years ago

This seams to do the trick! However, my image sits in a carousel... full page width, and touching the image to scroll down on mobile doesn't work..... I may make a mask that disappears on click, but which would allow a zooming afterwards.

ehigiej commented 2 years ago

I noticed that there are two types of listeners, some are set on document, by using document.addEventListener(..., others are set on the elements to bee zoomed, by using massAddEventListener($zoom....

While this makes the zooming work, I noticed that after calling zoom it breaks other scrolls in my web pages, since probably the document listeners "intercept" the event and prevent it to be used to scroll.

I think I've fixed this by setting all the event listeners using massAddEventListener($zoom... instead of document.addEventListener(..., which of course is not the same, but the zoom still works and I no longer have problems related to scrolling on mobile.

If the listener on document are considered important maybe this behaviour could be managed via a setting value?

I couldn't fix mine!!!!

ehigiej commented 2 years ago

I noticed that there are two types of listeners, some are set on document, by using document.addEventListener(..., others are set on the elements to bee zoomed, by using massAddEventListener($zoom.... While this makes the zooming work, I noticed that after calling zoom it breaks other scrolls in my web pages, since probably the document listeners "intercept" the event and prevent it to be used to scroll. I think I've fixed this by setting all the event listeners using massAddEventListener($zoom... instead of document.addEventListener(..., which of course is not the same, but the zoom still works and I no longer have problems related to scrolling on mobile. If the listener on document are considered important maybe this behaviour could be managed via a setting value?

I couldn't fix mine!!!!

Fixed it finally

davepilbeam commented 1 year ago

The above didn't work for me either, but the below did:

I just changed one of the handlers:

massAddEventListener($zoom,"touchmove", touchMove, {passive: false});

instead of

document.addEventListener("touchmove", touchMove, {passive: false});

First I tried replacing with

massAddEventListener("touchmove", touchMove, {passive: false});

but that didn't work either, so I targeted $zoom specifically.