Gallery: add touch swipe support for iPhone/iPad

This commit is contained in:
2026-05-16 10:37:10 +02:00
parent 63288dbb4b
commit eacd137a7c
4 changed files with 27 additions and 3 deletions
@@ -129,6 +129,18 @@ html = f"""<!DOCTYPE html>
document.getElementById('modal').addEventListener('click', function(e){{
if(e.target === this) closeModal();
}});
// Touch swipe support (iPhone/iPad)
let _tx = null;
document.getElementById('modal').addEventListener('touchstart', e => {{
_tx = e.changedTouches[0].clientX;
}}, {{passive: true}});
document.getElementById('modal').addEventListener('touchend', e => {{
if(_tx === null) return;
const dx = e.changedTouches[0].clientX - _tx;
_tx = null;
if(Math.abs(dx) < 40) return; // ignore taps
navigate(dx < 0 ? 1 : -1); // swipe left = næste, swipe right = forrige
}}, {{passive: true}});
function pruneSnapshots(){{
if(!confirm('Slet alle undtagen de 100 nyeste billeder?')) return;
const btn = document.getElementById('pruneBtn');