You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Love the PhotoSwipe plugin so far. So I would like to accomplish two things, depending on whether the gallery is viewed from a mobile device or not.
If browsing on a mobile device, I want the user to be able to click on the image to zoom in to max viewport.
If browsing on desktop, I want the user to not be able to zoom in at all. Instead, a click on the image should close the gallery.
I have tried several things but I can't get it to work. This is the code I have so far:
function isPhonePortrait() {
return window.matchMedia('(max-width: 600px) and (orientation: portrait)').matches;
}
var lightbox = new PhotoSwipeLightbox({
gallery: '.landscapes',
children: 'a',
initialZoomLevel: (zoomLevelObject) => {
if (isPhonePortrait()) {
return zoomLevelObject.fit;
} else {
return zoomLevelObject.vFill;
}
},
secondaryZoomLevel: (zoomLevelObject) => {
if (isPhonePortrait()) {
return zoomLevelObject.vFill;
} else {
return 'fit';
}
},
maxZoomLevel: 1,
This takes care of the zooming/non-zooming bit, but I don't know how to add the code to make the gallery close on a image click. I tried to add different variations of this code:
But it doesn't work. Any ideas what I need to enter here?
The text was updated successfully, but these errors were encountered:
lococola
changed the title
Change behavior of imageClickAction based on windows size?
Change behavior of imageClickAction based on window size?
Feb 12, 2023
Love the PhotoSwipe plugin so far. So I would like to accomplish two things, depending on whether the gallery is viewed from a mobile device or not.
If browsing on a mobile device, I want the user to be able to click on the image to zoom in to max viewport.
If browsing on desktop, I want the user to not be able to zoom in at all. Instead, a click on the image should close the gallery.
I have tried several things but I can't get it to work. This is the code I have so far:
This takes care of the zooming/non-zooming bit, but I don't know how to add the code to make the gallery close on a image click. I tried to add different variations of this code:
But it doesn't work. Any ideas what I need to enter here?
The text was updated successfully, but these errors were encountered: