ui icon indicating copy to clipboard operation
ui copied to clipboard

Mouse panning breaks zoom on Android (panMode: "mousemove")

Open zackpyle opened this issue 1 year ago • 9 comments

Describe the bug

When you enable mouse panning, it seems to break Android zooming. After you pinch to zoom in, you can't pinch to zoom our or back in or pan. It freezes. The toolbar buttons work, and you can exit, or move to the next gallery image. But once you pinch to zoom, and then let go, it stops working on that image.

Reproduction

Using Android Chrome:

  1. Tap the image to open fancybox
  2. Use fingers to pinch to zoom in
  3. Release fingers
  4. You can no longer use fingers to zoom, or to drag the enlarged image, you can only use the toolbar buttons

Note - Works as intended on iphone

Tested on a real Android phone (Galaxy A54) and in Browserstack (Galaxy S23 set using "real device" not emulation)

Additional context

Fancybox.bind('[data-fancybox="gallery"]', {
    loop: true,
    contentClick: "toggleMax",
    Images: {
        Panzoom: {
            maxScale: 2,
            panMode: "mousemove",
            mouseMoveFactor: 1.1,
            mouseMoveFriction: 0.12,
        }
    }
});

Commenting out these 3 lines fixes it:

// panMode: "mousemove",
// mouseMoveFactor: 1.1,
// mouseMoveFriction: 0.12,

zackpyle avatar May 02 '24 20:05 zackpyle

Hi,

First of all, you actually were not supposed to set mousemove mode for mobile devices because mobile devices don't have a mouse. But I'll take a look at what's so different about Android that causes this problem.

fancyapps avatar May 06 '24 11:05 fancyapps

Ok thanks! Is there a way to disable mousemove on mobile then? I just have it set like shown above for the page it is on (meaning it currently applies to all screen sizes)

zackpyle avatar May 07 '24 16:05 zackpyle

You simply set options based on your conditions, for example:

if (YOUR_CONDITION) {
  Fancybox.bind('[data-fancybox]', {
    // Options
  });
} else {
  Fancybox.bind('[data-fancybox]', {
    // Other options
  });
}

fancyapps avatar May 09 '24 10:05 fancyapps

Ok, can do. Is it expected to have to go through and enable or disable various features based on screen size/device?

zackpyle avatar May 09 '24 11:05 zackpyle

Sorry, I do not understand the question. What do you have in mind?

btw, another trick is to pass a method as an option, example:

Fancybox.bind('[data-fancybox]', {
  compact: false,
  contentClick: () => {
    return window.innerWidth > 500 ? "toggleMax" : "toggleCover";
  }
});  

https://jsfiddle.net/5t0hpsbq/

fancyapps avatar May 09 '24 15:05 fancyapps

Ok thanks. My question is basically based on your first response, is the expectation for me to turn off mousemove on mobile? Or should that be handled by Panzoom mousemove to check if it is possible to even run?

Like should it be checking itself with something like .on('touchstart' or .on('mousemove', to know if it can run or not?

zackpyle avatar May 09 '24 16:05 zackpyle

To be honest, the script just binds mousemove event and I am not sure (I might not remember it correctly, I wrote that part quite some time ago), but think I hoped that it would just would not trigger on devices without a mouse :)

fancyapps avatar May 09 '24 16:05 fancyapps

Haha, yeah. I probably would have guessed the same. Well, thanks for taking a look. Let me know if you find a fix for why it is treating Android differently 👍🏻

zackpyle avatar May 09 '24 16:05 zackpyle

@fancyapps @zackpyle Hi! I experienced the same bug on android devices. Zackpyle described it perfectly! This is the only issue I experienced that should be fixed: After I pinch to zoom in, I can't pinch to zoom out or back in or pan. Specifically it freezes! When I pinch zoom on any android devices on the opened fancybox modal then I stop the pinch zoom after that I can't move it anymore, it freezes. I need to refresh the page. On iPhone works properly as zackpyle wrote! Alternatively can I disable pinch zoom on the modal on android devices temporarily?

galbeni avatar Oct 19 '24 18:10 galbeni