Recently, I came across a very peculiar issue in Microsoft's Edge browser regarding the deltaX
values for wheel
events, where they seem to be inverted. This was quite surprising as it deviates from the behavior of other browsers I have tested, including Internet Explorer 11 which displayed the expected values.
You can witness this problem first-hand by running the following code snippet and using your mouse wheel or trackpad:
window.addEventListener('wheel', function(e) {
console.log(e.deltaX, e.deltaY);
});
For a hands-on experience, I have provided a full-page example (snippets might not fully capture this):
Check out the Fullpage Working Example here
In Edge, IE, and other browsers, scrolling down yields a positive value while scrolling up gives a negative one, which is expected. However, in Edge, when scrolling left, a positive value is returned, whereas scrolling right results in a negative value – contrary to all other browsers (including IE11 and older versions).
I have also created GIF videos demonstrating this issue, providing links for varying file sizes:
- IE11 GIF
- Edge GIF
The query at hand:
Why does this discrepancy exist, and is there a solution for effectively managing these compatibility concerns? Can we detect this feature? Is this behavior a bug, or is it detailed in any documentation?
The spec strongly indicates that this behavior is erroneous:
If a user agent scrolls as the default action of the wheel event then the sign of the delta SHOULD be given by a right-hand coordinate system where positive X, Y, and Z axes are directed towards the right-most edge, bottom-most edge, and farthest depth (away from the user) of the document, respectively.
Additional Notes:
- I have verified this on both a Windows 10 VM and a native laptop, with consistent behavior in both environments.
- This does not seem to be related to "natural"/inverted scrolling, as it is turned off on all systems and VM hosts tested, affecting only one axis.
- As a side note, I am unsure if
deltaZ
follows a similar pattern or if it is even supported, as I do not possess such an input device.
Bug Reporting:
I have submitted a bug report to Microsoft regarding this issue. You can view and track its progress here. Hopefully, it will be addressed promptly.