add mobile swipe navigation in fullscreen

This commit is contained in:
Johannes
2026-05-04 04:13:32 +02:00
parent b206e9dc1e
commit f0eb0fafe7

View File

@@ -203,6 +203,20 @@
z_drag=null;
if(document.fullscreenElement && z_scale>1) img.style.cursor='grab';
});
let t_start_x = 0, t_start_y = 0;
img.addEventListener('touchstart', e => {
if (!document.fullscreenElement) return;
t_start_x = e.touches[0].clientX;
t_start_y = e.touches[0].clientY;
}, { passive: true });
img.addEventListener('touchend', e => {
if (!document.fullscreenElement) return;
const dx = e.changedTouches[0].clientX - t_start_x;
const dy = e.changedTouches[0].clientY - t_start_y;
if (Math.abs(dx) > Math.abs(dy) && Math.abs(dx) > 50) {
dx < 0 ? next() : prev();
}
}, { passive: true });
document.addEventListener('fullscreenchange', ()=>{
if(!document.fullscreenElement) reset_zoom();
});