2

I have a jquery hover event that fires as you hover over an element. Trouble is, if you hover over the element multiple times it queues up the event sometimes leaving the element flashing for well, minutes depending how quick and for how long you hover over and hover out the element. I want to stop the propagation of the event so this queuing is eliminated.

$('.pui-search-item').hover( function() {
        $(this).find('.pui-actions').show('fade');
    }, function(){
        $(this).find('.pui-actions').hide('fade');

    });

How would I go about this, i have tried the various propagation functions with no effect.

Thanks in advance.

1
  • Does pui-search-item a list? Commented May 13, 2011 at 13:14

3 Answers 3

7

Try this:

$('.pui-search-item').hover( function() {
        $(this).find('.pui-actions').stop(true, true).show('fade');
    }, function(){
        $(this).find('.pui-actions').stop(true, true).hide('fade');

    });

Here is more info about stop() http://api.jquery.com/stop/

Sign up to request clarification or add additional context in comments.

Comments

3

Add a stop(true) function call before the animation, so it resets the queue.

4 Comments

Genius - thank you - now fixed with: $(this).find('.pui-actions').stop(true,true).show('fade');
@Haraldo remember that the second parameter controls whether it jumps. Personally I would leave it false so that it shows or hides starting from its current opacity.
Is this more solid and smooth than using hoverIntent plugin or maybe setting and interval?
@easwee It's certainly easier, and if it looks about the same I would stick with it. I've never used a plugin for it.
1

Try this link.

Your implementation shall change to:

$('.pui-search-item').hover(function() {
  $(this).find('.pui-actions').stop(true, true).fadeOut();
}, function() {
  $(this).find('.pui-actions').stop(true, true).fadeIn();
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.