FIX: hover tooltip could be out of the screen

This commit is contained in:
Julien Maille 2026-02-15 14:22:53 +01:00
parent 9a6d4da463
commit 127a57138b

View file

@ -496,6 +496,12 @@ export function initializeUIInteractions(player, api, ui) {
finalY = e.clientY - rect.height - 10;
}
// Ensure it stays within viewport
if (finalX < 5) finalX = 5;
if (finalY < 5) finalY = 5;
if (finalX + rect.width > winWidth - 5) finalX = winWidth - rect.width - 5;
if (finalY + rect.height > winHeight - 5) finalY = winHeight - rect.height - 5;
tooltipEl.style.transform = `translate(${finalX}px, ${finalY}px)`;
// Reset top/left to 0 since we use transform
tooltipEl.style.top = '0';