add mobile swipe navigation in fullscreen
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user