From 7d2f07146941fa1227d40b5caa2bb02ed6311baf Mon Sep 17 00:00:00 2001 From: Volpeon Date: Wed, 29 Dec 2021 20:29:52 +0100 Subject: Lightbox optimizations --- content/lightbox.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'content') diff --git a/content/lightbox.js b/content/lightbox.js index a3e3bc0..d6115b4 100644 --- a/content/lightbox.js +++ b/content/lightbox.js @@ -4,11 +4,11 @@ const mainEl = document.querySelector("main"); const lightboxEl = document.querySelector(".c-lightbox"); - const lightboxBgEl = document.querySelector(".c-lightbox__bg"); - const lightboxCloseEl = document.querySelector(".c-lightbox__close"); - const lightboxPrevEl = document.querySelector(".c-lightbox__prev"); - const lightboxNextEl = document.querySelector(".c-lightbox__next"); - const lightboxImgEl = document.querySelector(".c-lightbox__img"); + const lightboxBgEl = lightboxEl.querySelector(".c-lightbox__bg"); + const lightboxCloseEl = lightboxEl.querySelector(".c-lightbox__close"); + const lightboxPrevEl = lightboxEl.querySelector(".c-lightbox__prev"); + const lightboxNextEl = lightboxEl.querySelector(".c-lightbox__next"); + const lightboxImgEl = lightboxEl.querySelector(".c-lightbox__img"); const figureEls = Array.from(mainEl.querySelectorAll("figure")).map(el => el.querySelector("a")); const show = () => { @@ -29,11 +29,11 @@ }; const prev = () => { - setIndex(currentIndex === 0 ? currentIndex : currentIndex - 1); + currentIndex === 0 ? void 0 : setIndex(currentIndex - 1); }; const next = () => { - setIndex(currentIndex === figureEls.length - 1 ? currentIndex : currentIndex + 1); + currentIndex === figureEls.length - 1 ? void 0 : setIndex(currentIndex + 1); }; lightboxBgEl.addEventListener("click", hide); -- cgit v1.2.3-54-g00ecf