briancherne / jquery-hoverIntent

hoverIntent jQuery Plug-in

Home Page:https://briancherne.github.io/jquery-hoverIntent/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hover does not always call 'over' when using a timeout for 'out'

dirv opened this issue · comments

Hi,

I'm using hoverIntent for a menu system that incorporates a timeout for calling the 'out' handler. Closing and opening menus does not work as I'd expect. For two hover items A and B, if I move quickly from A to B to A again then I expect A to open, but it doesn't. There's a script to reproduce this issue on JSFiddle:
http://jsfiddle.net/d_ir/u31xjd5d/1/

From a quick look at the source, it would seem that the ob.hoverIntent_t does not get called for the mouseleave event on the first tab item.

I can workaround the issue by removing the "if (!ob.hoverIntent_s)" condition on line 101.

I'm not sure if this is something I'm doing wrong, or if this is a bug. Any help would be appreciated.

Thanks
Daniel

commented

This might be the same issue as #35. We'll see if the fix for that also fixes this.

commented

Upon further investigation, it looks like the plugin is actually working as designed.

In your example, the over function is first called for item A, but the out function is actually never called because the mouse pointer re-enters the item before the (half-second, in your case) timeout is up. The fact that "A" was closed is just a result of the over function that was called for item B, since it closes all open items before opening the target item.

At this point, however, item A is still considered "active" by the plugin, so its over handler will not be called again until it has a chance to deactivate via out--that is, the mouse pointer needs to leave item A for at least 500 ms.

I suspect that the specific behavior you're trying to achieve is discussed in #6 (and may be made even easier by #11 once it lands). (Contrary to what I'd said in the previous comment, this issue has nothing to do with #35.)

I'll close the issue now since it's not a bug in the plugin, but feel free to follow my advice from #6 or leave a comment if you have any more questions. Hope this helps!