Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if the browser has swipe navigation gestures enabled with Javascript?

I have JS swipe gestures for browsers without swipe navigation. However, for browsers with native swipe gestures, it'll sometimes trigger both the native gesture and my JS gesture.

It seems like each browser implements swipe gestures differently, so it's too hard to disable the native swipe gestures. Is there a way to detect if native swipe gestures are enabled? Then, I can disable my JS swipe gestures.

like image 285
Leo Jiang Avatar asked Apr 21 '26 00:04

Leo Jiang


1 Answers

Maybe you should check is this device has touch devices with one of three variants?

let isTouch1 = window.matchMedia("(pointer: coarse)").matches;
let isTouch2 = navigator.maxTouchPoints > 0;
let isTouch3 = 'ontouchstart' in window;
like image 166
Alex Nikulin Avatar answered Apr 23 '26 14:04

Alex Nikulin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!