Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - Preventing queuing up hover functions from fast mouse movements

This is an issue I seem to keep coming across. If for example I have a drop down navigation menu using a jQuery hover() function and I quickly move my mouse cursor over then off the <li> about 10 times, the subnavigation will appear, then disappear 10 times.

Is there any way to prevent this issue from occuring?

Thanks

like image 929
Probocop Avatar asked Nov 23 '10 14:11

Probocop


2 Answers

Yes, use the stop function !

$(this).stop().animate(...);

Or

$(this).stop().show();
like image 70
Flipke Avatar answered Sep 20 '22 00:09

Flipke


We use Hoverintent for our menus. Gives a smart delay before animating:

http://cherne.net/brian/resources/jquery.hoverIntent.html

like image 20
Gregg B Avatar answered Sep 21 '22 00:09

Gregg B