Gallery: add touch swipe support for iPhone/iPad
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user