From 4fe6ced2f0e1657969ab87966baf740f2fea2fc7 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sun, 19 Jun 2022 13:41:22 +0200 Subject: Improved lightbox --- content/lightbox.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'content') diff --git a/content/lightbox.js b/content/lightbox.js index e672d63..deb5cce 100644 --- a/content/lightbox.js +++ b/content/lightbox.js @@ -1,12 +1,14 @@ (() => { const mainEl = document.querySelector("main"); const lightboxContainerEl = document.querySelector(".js-lightbox"); - const lightboxEl = lightboxContainerEl.querySelector(".o-lightbox"); + const lightboxEl = lightboxContainerEl.classList.contains("o-lightbox") + ? lightboxContainerEl + : lightboxContainerEl.querySelector(".o-lightbox"); const lightboxCloseEl = lightboxEl.querySelector(".o-lightbox__close-btn"); - const lightboxPrevEl = lightboxEl.querySelector(".o-lightbox__prev-btn"); - const lightboxNextEl = lightboxEl.querySelector(".o-lightbox__next-btn"); + const lightboxPrevEl = lightboxEl.querySelector(".o-lightbox__nav-btn--prev"); + const lightboxNextEl = lightboxEl.querySelector(".o-lightbox__nav-btn--next"); const lightboxImgEl = lightboxEl.querySelector(".o-lightbox__img"); - const lightboxFooterEl = lightboxEl.querySelector(".o-lightbox__footer"); + const lightboxThumbnailsEl = lightboxEl.querySelector(".o-lightbox__thumbnails"); const figureEls = Array.from(mainEl.querySelectorAll(".js-lightbox__image")); const standalone = lightboxContainerEl.classList.contains("js-lightbox--standalone"); @@ -72,7 +74,7 @@ thumbnailButtonEl.appendChild(thumbnailImgEl); thumbnailButtonEl.addEventListener("click", go); - lightboxFooterEl.appendChild(thumbnailButtonEl); + lightboxThumbnailsEl.appendChild(thumbnailButtonEl); if (!standalone) { figureEl.firstElementChild.addEventListener("click", go); @@ -89,7 +91,7 @@ if (figureEls.length <= 1) { lightboxPrevEl.remove(); lightboxNextEl.remove(); - lightboxFooterEl.remove(); + lightboxThumbnailsEl.remove(); } if (!standalone) { -- cgit v1.2.3-70-g09d2