views:

29

answers:

2

I have a BG image animation that relies on the hover callback to revert to it's original state. If I move the mouse quickly over the links, the hovered state sticks. My guess is that I'm moving the mouse off before the first animation completes, so the callback doesn't register.

Is there a more bulletproof way to write this function?

$('.nav li a').hover(function() {
    $(this).addClass('hovered', 300);
}, function() {
    $(this).removeClass('hovered', 300);
});

(it uses a BGimg plugin to support the speed parameter on add/removeClass)

Testable here: McPherson Industries

A: 
Gaby
See my comment about the plugin. I added a link to it. Do the links roll up and down for you? And they don't stick? Whack. I've tried FF3 and Safari4, and it sticks in both of them if I go fast enough
Alex Mcp
yes, sorry about that.. just noticed it ..
Gaby
Thanks for the IE test; I'm on OS X.
Alex Mcp
+1  A: 
Tatu Ulmanen
That's a good start for me, thanks. I also sped up the time transition to 1/10th of a second (100) so it's a bit less likely to occur. These two changes make it much more usable; thanks.
Alex Mcp