Reputation: 970
I have an image with a play/pause button positioned absolute and centered over top.
see example; http://jsfiddle.net/GuJWk/3/
The button appears when the user hovers over the img, and disappears when the mouse leaves the image.
The problem i'm having is a flicker when the user hovers over the button, i suspect its because the images mouse out event has been triggered.
I know what the problem is and whats causing it, but i can't fix it. I don't want to nest the pauseplay button, to get it working either. I just need to manage the bubbling events some how..
Thanks, Cam
Upvotes: 0
Views: 152
Reputation: 8972
Does this solve your problem?
$("body").on("mouseover", "img", function(){
$('#pauseplay').stop(true,true).fadeIn(1000);
}).mouseleave(function(){
$('#pauseplay').stop(true,true).fadeOut(1000);
});
Upvotes: 2
Reputation: 348972
Add a .mouseenter
event to $('#pauseplay')
, which cancels the animation on hover:
$('#pauseplay').mouseenter(function(){
$(this).stop(false,false);
}).hide();
Also, $().hover(fn1, fn2)
is a shorthand for $().mouseenter(fn1).mouseleave(fn2)
.
Upvotes: 2