From 2ea8e9a472e4d726481a3ca99dbc988fb476e79e Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Mon, 11 May 2026 11:19:17 +0200 Subject: feat: swipe navigation in lightbox for mobile Co-Authored-By: Claude Sonnet 4.6 --- templates/gallery.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/templates/gallery.html b/templates/gallery.html index 51a7196..14e43c9 100644 --- a/templates/gallery.html +++ b/templates/gallery.html @@ -104,6 +104,17 @@ document.addEventListener('keydown', e => { if (e.key === 'ArrowRight' && currentIndex < photos.length - 1) openLightbox(currentIndex + 1); if (e.key === 'ArrowLeft' && currentIndex > 0) openLightbox(currentIndex - 1); }); + +let touchStartX = 0; +const lightbox = document.getElementById('lightbox'); +lightbox.addEventListener('touchstart', e => { touchStartX = e.touches[0].clientX; }, { passive: true }); +lightbox.addEventListener('touchend', e => { + if (currentIndex === -1) return; + const dx = e.changedTouches[0].clientX - touchStartX; + if (Math.abs(dx) < 50) return; + if (dx < 0 && currentIndex < photos.length - 1) openLightbox(currentIndex + 1); + if (dx > 0 && currentIndex > 0) openLightbox(currentIndex - 1); +}); -- cgit v1.3