-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
36 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
"use client"; | ||
import withDeferredMount from "@/lib/utils/deferredMount"; | ||
import PhotoSwipeLightbox from "photoswipe/lightbox"; | ||
import "photoswipe/style.css"; | ||
import { useEffect } from "react"; | ||
|
||
const LightBox = () => { | ||
useEffect(() => { | ||
const lightbox = new PhotoSwipeLightbox({ | ||
// may select multiple "galleries" | ||
gallery: "article", | ||
let lightbox; | ||
setTimeout(() => { | ||
lightbox = new PhotoSwipeLightbox({ | ||
// may select multiple "galleries" | ||
gallery: "article", | ||
|
||
// Elements within gallery (slides) | ||
children: "p figure", | ||
// Elements within gallery (slides) | ||
children: "a", | ||
|
||
// setup PhotoSwipe Core dynamic import | ||
pswpModule: () => import("photoswipe"), | ||
}); | ||
console.log(999,lightbox) | ||
lightbox.init(); | ||
// setup PhotoSwipe Core dynamic import | ||
pswpModule: () => import("photoswipe"), | ||
}); | ||
lightbox.init(); | ||
}, 200); | ||
return () => { | ||
lightbox.destroy(); | ||
lightbox = null; | ||
}; | ||
}, []); | ||
|
||
return <></>; | ||
}; | ||
|
||
export default withDeferredMount(LightBox, 100); | ||
export default LightBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,3 +152,7 @@ a { | |
/* Place on top of each other */ | ||
grid-area: 1 / 1 / 2 / 2; | ||
} | ||
|
||
.pswp__img { | ||
object-fit: contain; | ||
} |