summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2021-12-29 20:29:52 +0100
committerVolpeon <git@volpeon.ink>2021-12-29 20:29:52 +0100
commit7d2f07146941fa1227d40b5caa2bb02ed6311baf (patch)
treee419fb1b06487af32538865d6cc796f4da864bf1 /content
parentKeyboard-friendly lightbox (diff)
downloadvolpeon.ink-7d2f07146941fa1227d40b5caa2bb02ed6311baf.tar.gz
volpeon.ink-7d2f07146941fa1227d40b5caa2bb02ed6311baf.tar.bz2
volpeon.ink-7d2f07146941fa1227d40b5caa2bb02ed6311baf.zip
Lightbox optimizations
Diffstat (limited to 'content')
-rw-r--r--content/lightbox.js14
1 files changed, 7 insertions, 7 deletions
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 @@
4 4
5 const mainEl = document.querySelector("main"); 5 const mainEl = document.querySelector("main");
6 const lightboxEl = document.querySelector(".c-lightbox"); 6 const lightboxEl = document.querySelector(".c-lightbox");
7 const lightboxBgEl = document.querySelector(".c-lightbox__bg"); 7 const lightboxBgEl = lightboxEl.querySelector(".c-lightbox__bg");
8 const lightboxCloseEl = document.querySelector(".c-lightbox__close"); 8 const lightboxCloseEl = lightboxEl.querySelector(".c-lightbox__close");
9 const lightboxPrevEl = document.querySelector(".c-lightbox__prev"); 9 const lightboxPrevEl = lightboxEl.querySelector(".c-lightbox__prev");
10 const lightboxNextEl = document.querySelector(".c-lightbox__next"); 10 const lightboxNextEl = lightboxEl.querySelector(".c-lightbox__next");
11 const lightboxImgEl = document.querySelector(".c-lightbox__img"); 11 const lightboxImgEl = lightboxEl.querySelector(".c-lightbox__img");
12 const figureEls = Array.from(mainEl.querySelectorAll("figure")).map(el => el.querySelector("a")); 12 const figureEls = Array.from(mainEl.querySelectorAll("figure")).map(el => el.querySelector("a"));
13 13
14 const show = () => { 14 const show = () => {
@@ -29,11 +29,11 @@
29 }; 29 };
30 30
31 const prev = () => { 31 const prev = () => {
32 setIndex(currentIndex === 0 ? currentIndex : currentIndex - 1); 32 currentIndex === 0 ? void 0 : setIndex(currentIndex - 1);
33 }; 33 };
34 34
35 const next = () => { 35 const next = () => {
36 setIndex(currentIndex === figureEls.length - 1 ? currentIndex : currentIndex + 1); 36 currentIndex === figureEls.length - 1 ? void 0 : setIndex(currentIndex + 1);
37 }; 37 };
38 38
39 lightboxBgEl.addEventListener("click", hide); 39 lightboxBgEl.addEventListener("click", hide);