File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -188,12 +188,17 @@ try {
188188 // Initialize PhotoSwipe on all galleries
189189 function initializeGalleries() {
190190 const galleries = document.querySelectorAll(".photo-gallery-container");
191+ console.log("[PhotoGallery] Found containers:", galleries.length);
191192
192193 galleries.forEach((container) => {
193194 const gallery = container.querySelector(".gallery-grid");
194- if (!gallery) return;
195+ if (!gallery) {
196+ console.warn("[PhotoGallery] No .gallery-grid found in container");
197+ return;
198+ }
195199
196200 const galleryId = gallery.getAttribute("id") || "photo-gallery";
201+ console.log("[PhotoGallery] Initializing gallery:", galleryId);
197202
198203 const lightbox = new PhotoSwipeLightbox({
199204 gallery: `#${galleryId}`,
@@ -209,11 +214,17 @@ try {
209214 });
210215
211216 lightbox.init();
217+ console.log("[PhotoGallery] Lightbox initialized for:", galleryId);
212218 });
213219 }
214220
215- // Initialize on page load
216- initializeGalleries();
221+ // Initialize when DOM is ready
222+ if (document.readyState === "loading") {
223+ document.addEventListener("DOMContentLoaded", initializeGalleries);
224+ } else {
225+ // DOM already loaded
226+ initializeGalleries();
227+ }
217228
218229 // Re-initialize after Astro View Transitions
219230 document.addEventListener("astro:after-swap", () => {
You can’t perform that action at this time.
0 commit comments