From 5408aba01aed2e40fa2dce1b362d7940cf284be2 Mon Sep 17 00:00:00 2001 From: hbrain Date: Sun, 31 May 2026 15:19:39 +0200 Subject: [PATCH] Refine map lightbox UX and map click behavior across pages --- index.php | 4 ++-- js/map_lightbox.js | 22 +++++++++++----------- new.php | 4 ++-- style.css | 10 +++++++++- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/index.php b/index.php index f5282fd..af96d1b 100644 --- a/index.php +++ b/index.php @@ -255,7 +255,7 @@ $baseParams = ($rawKeyword !== '') ? ['q' => $rawKeyword] : []; $map = pathinfo($name, PATHINFO_FILENAME).".png"; if(is_file($config['videos_dir']."/".$map)): ?> - " alt="Map"> + ">" alt="Map">
@@ -305,6 +305,6 @@ $baseParams = ($rawKeyword !== '') ? ['q' => $rawKeyword] : []; }); })(); - + diff --git a/js/map_lightbox.js b/js/map_lightbox.js index 094d5c3..a7ca803 100644 --- a/js/map_lightbox.js +++ b/js/map_lightbox.js @@ -1,5 +1,5 @@ (() => { - const SELECTOR = 'img.map-image'; + const SELECTOR = 'a.map-image-link, img.map-image'; let lightbox = null; let lightboxImg = null; @@ -22,7 +22,7 @@ const hint = document.createElement('div'); hint.className = 'map-lightbox__hint'; - hint.textContent = 'Esc or click outside to close'; + hint.textContent = 'Esc or click/tap outside to close'; lightbox.appendChild(closeBtn); lightbox.appendChild(lightboxImg); @@ -30,21 +30,18 @@ document.body.appendChild(lightbox); closeBtn.addEventListener('click', closeLightbox); - lightbox.addEventListener('click', (ev) => { if (ev.target === lightbox) closeLightbox(); }); - document.addEventListener('keydown', (ev) => { - if (ev.key === 'Escape' && lightbox.classList.contains('is-open')) { - closeLightbox(); - } + if (ev.key === 'Escape' && lightbox.classList.contains('is-open')) closeLightbox(); }); return lightbox; } function openLightbox(src, alt) { + if (!src) return; ensureLightbox(); lightboxImg.src = src; lightboxImg.alt = alt || 'Map preview'; @@ -59,17 +56,20 @@ lightbox.setAttribute('aria-hidden', 'true'); document.body.classList.remove('map-lightbox-open'); setTimeout(() => { - if (!lightbox.classList.contains('is-open')) { - lightboxImg.removeAttribute('src'); - } + if (!lightbox.classList.contains('is-open')) lightboxImg.removeAttribute('src'); }, 260); } document.addEventListener('click', (ev) => { const target = ev.target instanceof Element ? ev.target.closest(SELECTOR) : null; if (!target) return; + + const img = target.matches('img.map-image') ? target : target.querySelector('img.map-image'); + const src = img ? (img.currentSrc || img.src) : target.getAttribute('href'); + if (!src) return; + ev.preventDefault(); ev.stopPropagation(); - openLightbox(target.currentSrc || target.src, target.alt || 'Map preview'); + openLightbox(src, img ? img.alt : 'Map preview'); }); })(); diff --git a/new.php b/new.php index e578508..75e2c9e 100644 --- a/new.php +++ b/new.php @@ -645,7 +645,7 @@ $runningJobs = active_worker_jobs($config);

Videos without input dir

No orphan videos.


MB
-

Existing input dirs

No input directories yet.

Map
No video yet
+

Existing input dirs

No input directories yet.

Map
No video yet
@@ -1098,5 +1098,5 @@ function applySwitchPayload(payload){ })(); - + \ No newline at end of file diff --git a/style.css b/style.css index 832238a..a33ad0e 100644 --- a/style.css +++ b/style.css @@ -45,14 +45,22 @@ } .describe-button{display:inline-block;margin-right:.6rem} +.map-image-link { + display: block; + margin-top: 1rem; + touch-action: manipulation; + -webkit-tap-highlight-color: transparent; +} .map-image { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #111315; border-radius: .5rem; - margin-top: 1rem; + margin-top: 0; cursor: zoom-in; + touch-action: manipulation; + -webkit-tap-highlight-color: transparent; transition: transform .22s ease, box-shadow .22s ease; } .map-image:hover {