I am trying to fix a bug with the mouseenter and mouseleave handler.
listener.addEventListener('mouseenter', function(){
element.style.visibility = "visible";
}, true);
listener.addEventListener('mouseleave', function(){
element.style.visibility = "hidden";
}, true);
The events work as expected except for when i am moving the mouse over the element it flashes the mouse leave event.
Any fixes for this?
Plain javascript solutions only, please (no 3rd party libraries).
The pointer in Javascript is only "hovering" the topmost (visible) element.
This means that if you've say a background div and when "entering" it you display another div on top of it the cursor will exit the background to enter the new div.
May be you can just set opacity to
0instead of hiding the div and leave it always "visible" (also placing the event handler in the appearing div, not in the background one).