Can you start the mouse so that it doesn't fire in IE on DOMready?

jQuery emulates the IE mouseenter event in non-IE browsers. In IE, however, mouseenter starts when the page loads (possibly due to the use of jQuery doScrollin the implementation $.ready), even if the mouse does not move at all.

This does not happen in other browsers and certainly does not follow the "Microsoft Specification" , which says (emphasis mine):

The event is triggered only if the mouse pointer is outside the object, and the user moves the mouse cursor inside the boundaries of the object. If the mouse pointer is currently inside the bounds of the object, for the event to be performed, the user must move the mouse pointer outside the bounds of the object , and then back inside the bounds of the object.

This becomes a usability problem if a navigation element (or hoverIntent plugin) is applied to the navigation element to display a drop-down menu or โ€œmega-menuโ€: in IE, mouseenter will launch immediately after $.ready, obscuring the contents using the menu.

+3
source share
2

: :

jQuery(function ($) {
    setTimeout(function () {
        /* bind with hoverIntent */
    }, 0);
});

IE ( ), jQuery $.ready.

+1

mousemove, DOM:

$(document).ready(function() {
    $(this).one('mousemove', function() { // only on the first time the mouse is moved
        $('#yourMenu').mouseenter(function() { // bind the mouseenter code
            // your code
        });
    });
});

, , .


setTimeout. $(window).load() :

$(window).load(function(){
    $('#yourMenu').mouseenter(function() { // bind the mouseenter code
        // your code
    });
});
+3

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


All Articles