JQuery mouseleave errors with animated elements

I ran into a strange problem.

jQuery 1.4.1 mouseenter / mouseleave events fire correctly if the mouse moves, and not a big deal. However, this is a bug in some browsers when the cursor itself remains static, but the element is removed by animation ().

Imagine this code:

jQuery('somelement').bind(
{
   mouseenter: function(e) {
     log.debug("enter");
     $(this).animate({left: 9999}, 2000);
   },
   mouseleave: function() {
     log.debug("leave");
   }
});

if you quickly move the mouse over an element and then stop it, you will get different results depending on the browser.

FF3.6, Safari 4, IE7: mouseleave fires as expected when the cursor leaves the animated element, even if the mouse itself is stationary.

IE6, IE8, Opera 9/10, Safari 3, Chrome: mouseleave does NOT start even when the item is outside the window. To trigger the correct mouseleave event, a slight mouse movement is required.

, ?

+3
1

, , mouseover, mouseleave, mouseover mouseout , . : onmouseout ..

, , . , .

  • mouseenter . , mousemove.
  • mousemove, x y .
  • , while. while , x y, 2.
  • x y, , , mousemove ( ). , , 1.

, . , , , .

0

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


All Articles