FIX: hover tooltip could be out of the screen
This commit is contained in:
parent
9a6d4da463
commit
127a57138b
1 changed files with 6 additions and 0 deletions
|
|
@ -496,6 +496,12 @@ export function initializeUIInteractions(player, api, ui) {
|
||||||
finalY = e.clientY - rect.height - 10;
|
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)`;
|
tooltipEl.style.transform = `translate(${finalX}px, ${finalY}px)`;
|
||||||
// Reset top/left to 0 since we use transform
|
// Reset top/left to 0 since we use transform
|
||||||
tooltipEl.style.top = '0';
|
tooltipEl.style.top = '0';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue