Having trouble with the unexpectedly reversed wheel event deltaX in Microsoft Edge browser?

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.

Answer №1

As we anticipate an official response from Microsoft, potentially in the form of an update to address this problem, I have discovered a method to determine if the browser is providing an incorrectly inverted deltaX.

In addition to this, Edge has introduced support for the non-standard properties wheelDeltaX, wheelDeltaY, and wheelDelta, which are also present in Chrome. Unlike deltaX, these values are accurate and represent the actual wheel change rather than a computed result. Even though their specific values may not be crucial, we can use them to deduce the correct sign value.

In Chrome, the sign values for deltaX and wheelDeltaX are correctly different; when one is negative, the other is positive. This suggests that if both values share the same sign (either negative or positive), it indicates that the signed value of deltaX is incorrect, as it currently is in Edge. Thus, by utilizing this property, we can detect the erroneously inverted value and restore its proper orientation.

Below is a function wrapper that I developed to resolve this issue.

function wheelDeltaX(e) {
    // Retrieve the reported deltaX.
    var r = e.deltaX;

    // In Edge, the deltaX inaccurately aligns with the wheelDeltaX sign.
    // If both sign values match, then un-invert it.
    var wheelDeltaX;
    if (
        r &&
        (wheelDeltaX = e.wheelDeltaX) &&
        (
            (r < 0 && wheelDeltaX < 0) ||
            (r > 0 && wheelDeltaX > 0)
        )
    ) {
        r = -r;
    }

    return r;
}

Assuming that Edge maintains the correct signing for wheelDeltaX after resolving the issue, this solution should remain effective in the future.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Aligning a lowercase "i" element within a container

Is there a more effective way to center the "i" element within this div without using specific pixel margins that adjust based on hover? Below is my code snippet: HTML: <div class="nav-collapse"> <i class="fa fa-bars fa-2x" id="bars"></ ...

React-Query: executing a function after updating query data

After updating the cache in a form, triggered by a response from the server, I utilize setQueryData. However, following this cache update, my goal is to refocus on the form input field. Here are some details: Within my React application, I employ Recoil. ...

Saving changes made in HTML is not supported when a checkbox is selected and the page is navigated in a React application using Bootstrap

In my array, there are multiple "question" elements with a similar structure like this: <><div className="row"><div className="col-12 col-md-9 col-lg-10 col-xl-10 col-xxl-10"><span>Question 1</span></div ...

Explore how to effectively use multiple values in a jQuery filter function when working with data attributes

Exploring the use of jQuery filter for data attributes with tables that contain team, specialization, and level data variables. Seeking advice on the best approach and typical usage methods. Here is my HTML code: <table data-team="<?php print $name[ ...

The table refuses to load

I've been troubleshooting this issue for the past two days. The array is visible in the console, but it refuses to show up on the table. I've tried multiple approaches, but none seem to work. I suspect that "tobodyHtml" is not defined properly, a ...

When the onload event is triggered, the jscript function called var data is loaded, without any interruption in

I encountered an issue while trying to preview an image from a BBCode decoder. The code works fine, but I need the image to be inside an <a> href link, so that people can click on it and get the image source. Additionally, I want to display a message ...

Error encountered when attempting to retrieve data from a JSON object

I'm in the process of extracting some information from a JSON object, but I've encountered a confusing issue. The JSON object structure is as follows: { "status": "success", "data": { "image": null, "video": null, "author": null, "publisher": "M ...

How to format numbers with commas in AngularJS to make them easier to read

One of my variables looks like this: $scope.numbers = 1234567. When I apply the filter {{numbers| number : 0}}, the result is 1,234,567. Is it possible to get a result like 12,34,567 instead? Thank you in advance. ...

UnknownReferenceError: jwreload has not been declared (Exploring dynamic routing in next.js)

Error in dynamic route with next.js Recently, I started learning next.js and encountered an issue while implementing a dynamic route. The error message "ReferenceError: jwreload is not defined" keeps appearing whenever I reload the page. Surprisingly, des ...

Tips for reducing the size of the sidebar when navigating to a specific page

I have a sidebar that I want to minimize when the user enters the index page. There is a button in the sidebar for that: <a class="mobile-menu" id="mobile-collapse" href="javascript:"><span></a> How can I au ...

updating the v-model in Vue.js datepicker retains the previously set value while setting a new date

When using the template, the endDate updates as expected. However, there seems to be an issue when the filtersChanged method is called with the @selected attribute - the updated value is not the new one but rather the previously set value. <template&g ...

Issues with Skrollr JS on mobile device causing scrolling problem

Currently facing an issue with Skrollr js. It is functioning perfectly in web browsers and mobile devices. However, there seems to be a problem when tapping on a menu or scrolling down arrow as it does not initiate scrolling. Assistance would be greatly ...

Creating an HTML table dynamically through JavaScript within a script block

I am working on using a JavaScript API to send emails, with the ability to include HTML. I am trying to create a table inside the email body, but it doesn't seem to be displaying properly. Here is the code snippet I'm using: <script> $ ...

What is the best way to store a jQuery AJAX response in a PHP variable?

How can I pass a jQuery ajax response into a PHP variable after success in my code: process.php $start = ""; $end = ""; if(isset($_POST['tampStart'])) { $start = $_POST['tampStart']; } if(isset($_POST[& ...

How to remove outer quotes from JSON data in Reactjs after using JSON.stringify

When using JSON.stringify on a Json data, I noticed that the resulting string includes double quotes at the beginning and end. For example: x = {fieldId: 536, value: {value: 341, display_value: "ABCD"}} After using JSON.stringify, the result looks like t ...

What is the reason this JavaScript code functions properly within a <script> tag but not when placed in a separate .js

After researching various image sliders online, I came across this specific one. It worked perfectly fine when I included the JavaScript directly in a script tag within the HTML file. However, as soon as I tried to link it via a .js file, the slider stoppe ...

What is the best way to replace multiple strings with bold formatting in JavaScript without losing the previous bolded text?

function boldKeywords(inputString, keywords){ for (var i = 0; i < keywords.length; i++) { var key = keywords[i]; if (key) inputString= inputString.replace(new RegExp(key, 'gi'), '<strong>' + ...

Adding Array Elements to List Elements

I am facing an issue while trying to display an array of items in a list. The problem is that when I click submit, it adds all the array items to each list item instead of adding one item each time. Here is the link to JSFIDDLE: https://jsfiddle.net/b7Lw ...

Having trouble with the functionality of the React Infinite Scroll component

Here is how I am implementing the react-infinite scroll component: const [hasMore, setHasMore] = useState(true) const [pageNumber, setPageNumber] = useState(1) const fetchDataOnScroll = async () => { try { const res = await axios.get( ...

Accessing and parsing JSON data from directories within directories

My file directory structure is dynamic, with only the name of $(Root Directory) known at runtime. All folders and files are generated dynamically, with all files being in .json format. I am looking to count the number of files and read the content of eac ...