w3c / uievents

UI Events
https://w3c.github.io/uievents/
Other
147 stars 52 forks source link

Change DOM_DELTA_PIXEL to be intended scroll distance instead of exact scroll distance #249

Open InstyleVII opened 4 years ago

InstyleVII commented 4 years ago

In Edge when we scroll we actually scroll a percentage of the scroller's bounds for every wheel tick. We've found this leads to a more consistent scrolling experience and ensures that regardless of scroller size the user get's a proportionate scroll every time. When we did this in EdgeHTML we misreported the deltaY value to always be a percentage of the root scroller (we didn't account for sub-scrollers). Note that we did however scroll the correct amount (15%) for both root and sub-scrollers, the deltaY was just misreported.

In Chromium we actually try to follow the spec and report the distance for deltaY however we've noticed compatibility issues with websites who implement their own custom scrolling behavior. Specifically, it's non-obvious which scroller the percentage was resolved against. Consider the scenario where an element is overlaying a scroller and is listening to the wheel event. If the listening element's ancestor is not the scroller, the percentage is resolved against some outer scroller. This causes the reported delta value to not be accurate for what the page is intending to do.

To that end for compatibility the DOM_DELTA_PIXEL value should be allowed to be the intended scroll distance the browser thinks it should scroll instead of the actual pixel value.