Jquery to allow only one rollover

I created the .slideDown and .slideUp for a div based on mouseover and mouseleave .

The problem is that when I flip a few divs so that quickly, and then rolloff, it seems to remember how many times I rolled and did not stop until all the slide windows and slide buttons were completed.

Example: http://juliosalvat.com/IconTest/

+4
source share
2 answers

Yes, it's nasty. JQuery saves the event queue to shorten this queue, you can use .stop()

http://api.jquery.com/stop/

You might need .stop(true, true) , which will remove all the animation in the queue and just play the last one.

+4
source

You should look into the HoverIntent jQuery plugin

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

hoverIntent is a plugin that tries to determine user intention ... like a crystal ball, with just a mouse movement! It works like (and was derived from) jQuery's built-in hang. However, instead of immediately calling the onMouseOver function, it waits until the user mouse slows down before making the call.

+1
source

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


All Articles