Ask Your Question
2

What is the method to turn off double tap scrolling with the use of CSS or Javascript?

asked 2022-05-02 11:00:00 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-01-02 08:00:00 +0000

lakamha gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-05-02 11:00:00 +0000

Seen: 8 times

Last updated: Jan 02 '22