Quirks with Web JS
Here I document all the quirks I've encountered while writing Javascript code for web projects.
Mouse events
mouseenter
doesn't bubble likemouseover
event.clientX
andevent.clientY
are unreliable and inconsistent for obtaining cursor position. Instead, use{ top, left }
fromevent.getBoudingClientRect()
I tried adding a popup element on hover but its positioning was inconsistent. The cursor entering from the top vs from the bottom resulted in different positions for the popup. affected