21

I have a page where the user can scroll horizontally the content, and in Chrome this scroll action sometimes triggers the two fingers back/forward swipe.

How can I deactivate this Chrome's function in a specific page, without disabling horizontal scroll?

raulmarcosl
  • 793
  • 1
  • 6
  • 10
  • 1
    It doesn't look like it's possible to change it as a developer; only as a user. See [How do I disable Chrome's two-finger back/forward navigation?](http://apple.stackexchange.com/q/21236) and http://productforums.google.com/forum/#!topic/chrome/PaMriZC-Kuo – Danny Beckett Jul 04 '13 at 16:38
  • Check my answer/example here (it may help): https://stackoverflow.com/questions/15829172/stop-chrome-back-forward-two-finger-swipe/45037801#45037801 – Florin David Jul 11 '17 at 14:47
  • Check my answer/example here (it may help): https://stackoverflow.com/questions/15829172/stop-chrome-back-forward-two-finger-swipe/45037801#45037801 – Florin David Jul 11 '17 at 14:52
  • Does this answer your question? [Stop chrome back/forward two finger swipe](https://stackoverflow.com/questions/15829172/stop-chrome-back-forward-two-finger-swipe) – Sumit Jun 21 '23 at 10:49

4 Answers4

34

After way too long, I discovered this:

html, body {
  overscroll-behavior-x: none;
}
tbjgolden
  • 1,115
  • 8
  • 9
  • 1
    @MattSanders you probably need to set it on another DOM element. For me it works using the same Chrome version. – gerric Sep 06 '19 at 09:46
  • @gerric - hmm, thanks. Is it working for you on `body` or a different element? – Matt Sanders Sep 20 '19 at 21:56
  • 6
    In case this helps someone else, `body` and the element with `overflow` on it didn't work, but putting `overscroll-behavior-x` on the `html` element itself did work for me. – Matt Sanders Oct 01 '19 at 23:45
5

I have found that this chrome setting disabled the behavior: chrome://flags/#overscroll-history-navigation

Just disable overscroll, it will disable the page navigation using the scroll but normal horizontal scroll on the page will work. Tested on my end.

JKillian
  • 18,061
  • 8
  • 41
  • 74
Satyam Naolekar
  • 560
  • 7
  • 10
3

Go to Chrome flags by pasting Chrome://flags in the address bar and search for Overscroll history navigation and change this from default to Disabled

It will prompt to restart the browser, restart it.

This should solve it.

Ramkrishan Sahu
  • 194
  • 1
  • 5
2

It is only possible to disable this feature by disabling scrolling itself:

With jQuery:

('body').on('wheel', function(e){ e.preventDefault(); });

Without jQuery:

document.body.addEventListener('wheel', function(e){ e.preventDefault(); });

This code will work in Modern browsers but is not cross-browser tested. Also, MAJOR CAVEAT: if you still want the users to be able to scroll the page, you'll have to roll your own scrolling to make it all work.

Anson Kao
  • 5,256
  • 4
  • 28
  • 37