Windows 10 - Precision Touchpad - Unable to prevent scrolling DOMMouseScroll
Categories
(Core :: DOM: Events, defect, P3)
Tracking
()
People
(Reporter: roland, Unassigned)
References
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36
Steps to reproduce:
- On Windows 10 with Precision Touchpad (Virtual touchpad works fine) open: https://jsfiddle.net/wutx16o4/
- Scroll the red area with 2 finger scroll on the touchpad
Actual results:
The page scrolls away.
Expected results:
It shouldn't scroll away as the event has .preventDefault(); call:
document.getElementById('div1').addEventListener('DOMMouseScroll', function(e){
e.preventDefault();
});
Comment 1•6 years ago
|
||
Hi @roland, I cannot see any differences between Firefox & Chrome, on both sides there are the same result. Please try in Firefox with Add-ons disabled and then test in other browsers (e.g. Chrome) and let me know the results. Thanks.
Thanks for the reply. I see what I did there. In my original code I used 'DOMMouseScroll' event for Firefox and 'mousewheel' event for Chrome.
Now I started to use the 'wheel' event and if I use this, I'm able to prevent the scroll on 2 finger touchpad drag.
But Firefox dispatch for this interaction 'DOMMouseScroll' events and while this event comes from a real mouse, I can prevent the scroll just fine. But if this event comes from the touchpad, then I'm unable to prevent the scroll.
So if you check this example: https://jsfiddle.net/v0xhzt3q/1/
Chrome will prevent the scroll while Firefox will allow scroll.
And this example with 'wheel' event will work fine in Firefox too:
https://jsfiddle.net/v0xhzt3q/2/
Comment 3•6 years ago
|
||
Hi @roland, I've re-tested the issue.
[Firefox version affected]: latest nightly 68.0a1, beta 66, release 65.0.2 - on all versions the example https://jsfiddle.net/v0xhzt3q/1/ - cannot prevent scroll. In the 2nd example: https://jsfiddle.net/v0xhzt3q/2/ - the scroll works accordingly.
Additionally, both examples ('DOMMouseScroll' / 'wheel') can prevent scroll if there are rendered in other browser e.g Chrome.
I will set a component and if this isn't an appropriate one someone from dev's team could change it.
Comment 4•6 years ago
|
||
I can't reproduce the issue on linux. Will test Win10 later.
Masayuki, does this ring any bells?
Comment 5•6 years ago
|
||
https://searchfox.org/mozilla-central/rev/7abb9117c8500ed20833746c9f8e800fce3a4688/dom/events/EventListenerManager.cpp#1692-1697 treats the events the same way.
But, is this about MozMousePixelScroll event? I guess this laptop doesn't end up dispatching those.
wheel event is of course the one one should always use.
Comment 6•6 years ago
|
||
roland, if you try preventDefault() on MozMousePixelScroll too, does it help?
(but, as I said, wheel event is the one to use, that is the only one defined in a specification. mousewheel and DOMMouseScroll and MozMousePixelScroll are legacy events, and shouldn't be used.)
The result with MozMousePixelScroll is the same with DOMMouseScroll. I was able to scroll down. https://jsfiddle.net/zod5fvje/
Ps.: I know these are legacy event, but they might indicate underlying issues.
Please also note that only Windows 10 Precision Touchpad affected (or touchscreen with Virtual Touchpad).
Comment 9•6 years ago
|
||
With MozMousePixelScroll
, I see the expected result (comment 7). And I confirmed the comment 0 case won't work as expected (i.e., scrolled smoothly).
Only with DOMouseScroll
, you cannot prevent scroll unfortunately because only MozMousePixelScroll
and wheel
events are dispatched in most cases if you use high-resolution wheel. Only when accumulated scroll amount reaches 1 or -1 line, DOMMouseScroll
event is also fired, therefore, it looks like that preventing the default of DOMMouseScroll
does nothing because for example, the default of one of 100 wheel events is prevented.
(Note that I'm struggling with this compatibility issue in bug 1406243, but I've not found a smart way yet.)
Updated•4 years ago
|
Comment 10•4 years ago
|
||
I think this should be fixed now that we use dmanip with precision touchpads. Could you check if it's working for you now?
Reporter | ||
Comment 11•4 years ago
|
||
I tried it in Firefox 90 and this issue solved.
Description
•