Photoswipe: Disable zoom function

Created on 22 May 2015  路  6Comments  路  Source: dimsemenov/PhotoSwipe

great script! thank you

i just try to disable the zoom function on the images, when there isn't enough space to display it

i tried :

allowUserZoom: false,

but it doesn't work

anybody has an idea ?

thank you

Implementation Question

Most helpful comment

I've managed to disable all zoom on desktop using following settings (notice return item.initialZoomLevel;)

{
  zoomEl: false,
  maxSpreadZoom: 1,
  getDoubleTapZoom: function(isMouseClick, item) {
    return item.initialZoomLevel;
  }
  pinchToClose: false
}
.pswp--zoom-allowed .pswp__img
  cursor default !important

All 6 comments

There is no option to disable zoom entirely, but you may set max zoom level to original size (1) Check options maxSpreadZoom, getDoubleTapZoom, pinchToClose. http://photoswipe.com/documentation/options.html

I've managed to disable all zoom on desktop using following settings (notice return item.initialZoomLevel;)

{
  zoomEl: false,
  maxSpreadZoom: 1,
  getDoubleTapZoom: function(isMouseClick, item) {
    return item.initialZoomLevel;
  }
  pinchToClose: false
}
.pswp--zoom-allowed .pswp__img
  cursor default !important

i'm using the justified image grid wordpress plugin. where would this snippet need to be installed? in photoswipe4.js within the jig plugin directory?

Thank you very much @chodorowicz !!!

Justified Image Grid author chiming in. I'm adding the solution by @chodorowicz as an option to the next update of my plugin. You'll be able to disable zooming of the opened large image and/or to disable the thumbnail zoom animation when opening. Cursor will get handled automatically behind the scenes.

On Android, the solution doesn't kill the pinch zoom though. I don't think it's much of a problem as it looks nice and native to have zoom on the devices, even though on dekstop the user might want to disable it. For example many smaller-than-screen landscape images fit just nicely, but the zoom feature activates just for a single portrait image. It might turn out to be weird.

grab cursor for mouse dragging when zoom is disabled

.pswp--zoom-allowed
    .pswp__img
        cursor grab
        &:active
            cursor grabbing
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamminjames picture jamminjames  路  3Comments

rnnyrk picture rnnyrk  路  5Comments

marten-seemann picture marten-seemann  路  4Comments

rafinha90 picture rafinha90  路  4Comments

slowaways picture slowaways  路  4Comments