Slide effect happens too many times
I am calling these functions in onmouseover and onmouseout for multiple divs.
//Takes effect on divs with id, 62,63,64,65...
function slide_it(id){
$('#options_'+id).slideToggle('slow');
}
The problem is that if I move the mouse over and then pull out with the mouse, then move the mouse over and pull out with the mouse again. If I do this multiple times, the slide effect happens as many times as I clicked on the mouse and out of the div as expected.
But I can't figure out how can I do this one time ? I can set a variable, but I have multiple divs that are being used by this function and I can't think of an easy way to do this, not store things in an array, but it's messy!
I really appreciate any help on this, which is easy to implement!
Thanks everyone for the help
a source to share
Before you call slideToggle()
, use .stop(true)
, this ends the current animation (if any), and since you are chaining, immediately start the animation you provide, for example:
$('#options_'+id).stop(true).slideToggle('slow');
When
.stop()
called on an element, the current animation (if any) stops immediately. If, for example, an element is hidden with.slideUp()
when called.stop()
, the element will now be shown but will be part of its previous height. Callback functions are not called.
Example: if you hover the cursor quickly and quickly, I didn’t wait for it to slide, it stops it and starts jumping out as soon as the mouse leaves.
a source to share