clickercookie / clickercookie.github.io

A totally original game about clicking a cookie
GNU General Public License v3.0
3 stars 0 forks source link

Infobox flickers randomly when hovering over buildings #24

Closed FifthTundraG closed 4 months ago

FifthTundraG commented 4 months ago

Update: It has something to do with the elements inside the building elements, when you remove the building-content and building-icon elements, the issue is no longer present. Confusingly, in the following line of code, changing mousePos.y - tooltip.offsetHeight/2 to mousePos.y - 50 (or any other integer) will also fix the bug, although there appears to be no issue with the mouse's Y position or the offsetHeight of the tooltip.

const tooltip = document.getElementById("tooltip");
tooltip.style.top = clamp(mousePos.y - tooltip.offsetHeight/2,0,window.innerHeight-(tooltip.offsetHeight + 1))+"px";

The clamp() function has no effect on the bug.

FifthTundraG commented 4 months ago

Fixed by having both onmouseover AND onmousemove attached to the building element, not sure why it actually was broken in the first place, though, will look into why in 0.7 and ways it can be improved.