I am facing an issue with the mouseenter
/mouseleave
functions in Firefox. I need to perform the following steps:
- Move the node to a different location in the DOM after it registers a mouse enter event
- Return the node to its original position after it registers a mouse leave event
The problem arises when the node is inserted into a different place, as mouseenter
fires multiple times and mouseleave
doesn't fire at all.
Here's a link to a pen that demonstrates this behavior. Check the console output to see how many times the mouseenter event is triggered. While it may seem confusing in the pen example, it's causing issues in my application. I have implemented zoom functionality for images on hover, but one of the ancestors has overflow: hidden
which hides parts of the enlarged image. To address this, I move the image within the DOM structure while ensuring it remains in the same screen position, then return it back once the zoom effect is over (when mouse leaves the image).
Question:
Could someone shed light on what is happening here? And provide guidance on resolving this to achieve the expected behavior of mouseenter
and mouseleave
events being triggered only once?