FancyBox for WordPress Panning Image Auto Zooms Out

FancyBox for WordPress is undoubtly one of the best image plugins for WordPress. Not only does it not affect page load times but has just the right bells and whistles. :slight_smile:
When using FancyBox for WordPress for a WP-post:

  1. Click an image to open in lightbox
  2. Click the image in lightbox to zoom in the image
  3. Pan an image by holding down a mouse click
  4. Release the mouse click

On step 4 you will notice the image auto zooms out. This is because letting go of a pan counts as a click on the image; hence it zooms out. If you pan (long click) and bring the cursor to the OS menu bar (outside browser viewport) the image pans and doesn’t auto zoom out. We need to have a way so that a long click release doesn’t auto zoom out.

Hey there,

Thanks for contacting us, but its not an our issue, first you need to get in touch with the FancyBox support about this and let them know the problem, most probably they can provide some solution for you.

Regards,

Hello, @Josh
To prevent FancyBox from auto-zooming out when you release the mouse click after panning, you can customize the FancyBox settings. Here’s how you can achieve this:

Disable Click to Zoom: Use the clickContent option to disable the zoom functionality when clicking on the image.
Custom JavaScript: Implement custom JavaScript to handle the panning and prevent the auto-zoom out behavior.
Here’s an example of how you can modify your FancyBox initialization:

$(ā€œ[data-fancybox]ā€).fancybox({
clickContent: function(current, event) {
// Prevent zoom out on click after panning
if (current.type === ā€˜image’) {
return false;
}
},
// Other options
thumbs: false,
hash: false,
loop: true,
keyboard: true,
toolbar: false,
animationEffect: false,
arrows: true
});

This code snippet ensures that clicking on the image after panning does not trigger the zoom out action.

I hope this info is helpful to you.

Best Regard,
Gregory Chavez

Hey there,

Thank you for your suggestion Gregory :slight_smile:

Regards,