PhotoSwipe
PhotoSwipe copied to clipboard
bgClickAction not working on mobile
Hi, I have this code:
const closeGallery = (pt, evt) => {
if (evt.target.classList.contains('pswp__img')) {
pswp.next();
} else {
pswp.close();
}
}
lightbox = new PhotoSwipeLightbox({
dataSource,
pswpModule: () => import("photoswipe"),
doubleTapAction: "zoom",
bgClickAction: (pt, evt) => closeGallery(pt, evt),
});
It seems like bgClickAction isn't triggering on mobile, while debugging the breakpoint is not hit.
PS version: 5.4.4
I missed the part where it says in the docs that it only captures mouse clicks. Is there an action for tap? :)
find a solution?
Yep, in my case I close the gallery on bg click.
lightbox.pswp.on("pointerUp", (ev) => {
const isBgClick = [...ev.originalEvent?.target?.classList].includes("pswp__item");
if (isBgClick) {
lightbox.pswp.close();
}
})