Define OS x "Natural Scrolling Direction" in Chrome & FF using javascript / jQuery

I ran into a problem. I am trying to determine if an OS x user has a "natural scroll direction" when using chrome or FF. Currently, I can detect it if the user is in Safari using the following code.

$("html, body").bind({'mousewheel DOMMouseScroll onmousewheel touchmove scroll': function(e, delta) { if(Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0) { if(e.originalEvent.webkitDirectionInvertedFromDevice) { this.scrollTop += (delta); e.preventDefault(); } }}}); 

This stackoverflow page helped me with the above safari-only solution. Javascript: OS X discovery "natural scroll" Settings

Is it possible to detect it using chrome and FF. The reason I need it is because I want to make the user scroll in the “Reverse Scroll Direction”, in other words, when the user scrolls down, I need the page to go down.

Help is much appreciated! :)

+5
source share

Source: https://habr.com/ru/post/1241013/


All Articles