In CSS, the method to turn off double tap scrolling is by applying the following style to the HTML or body element:
html, body {
touch-action: none;
}
In JavaScript, you can add an event listener to the HTML or body element to prevent double tap scrolling like this:
document.querySelector('html').addEventListener('touchstart', function(e) {
if (e.touches.length > 1) {
e.preventDefault();
}
}, { passive: false });
This code block prevents default behavior when two or more touch points are detected, effectively turning off double tap scrolling.
Asked: 2022-05-02 11:00:00 +0000
Seen: 8 times
Last updated: Jan 02 '22