Add dynamic photoswipe padding
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
import PhotoSwipeLightbox from "photoswipe/lightbox";
|
import PhotoSwipeLightbox from "photoswipe/lightbox";
|
||||||
import Masonry from "masonry-layout";
|
import Masonry from "masonry-layout";
|
||||||
|
|
||||||
const lightboxCaptionHeight = 5 * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
||||||
|
|
||||||
const lightbox = new PhotoSwipeLightbox({
|
const lightbox = new PhotoSwipeLightbox({
|
||||||
gallery: ".lightbox",
|
gallery: ".lightbox",
|
||||||
children: ".pswp-image",
|
children: ".pswp-image",
|
||||||
@@ -10,12 +8,16 @@ const lightbox = new PhotoSwipeLightbox({
|
|||||||
hideAnimationDuration: 300,
|
hideAnimationDuration: 300,
|
||||||
initialZoomLevel: "fit",
|
initialZoomLevel: "fit",
|
||||||
pswpModule: () => import("photoswipe"),
|
pswpModule: () => import("photoswipe"),
|
||||||
padding: {
|
paddingFn: () => {
|
||||||
top: lightboxCaptionHeight,
|
const captionHeight =
|
||||||
bottom: lightboxCaptionHeight,
|
5 * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
||||||
left: 0,
|
return {
|
||||||
right: 0,
|
top: captionHeight,
|
||||||
}
|
bottom: captionHeight,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
};
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
lightbox.on("uiRegister", function () {
|
lightbox.on("uiRegister", function () {
|
||||||
|
Reference in New Issue
Block a user