aboutsummaryrefslogtreecommitdiff
path: root/templates/gallery.html
diff options
context:
space:
mode:
Diffstat (limited to 'templates/gallery.html')
-rw-r--r--templates/gallery.html11
1 files changed, 11 insertions, 0 deletions
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);
+});
</script>
</body>
</html>