mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
move tooltip away from edges
This commit is contained in:
parent
72609bee18
commit
4a04ccd96c
1 changed files with 7 additions and 2 deletions
|
@ -12,9 +12,14 @@ function showTooltipInner(msg: string, x: number, y: number): void {
|
|||
document.body.appendChild(tooltipDiv);
|
||||
}
|
||||
tooltipDiv.innerHTML = msg;
|
||||
tooltipDiv.style.right = `${document.body.clientWidth - x + 10}px`;
|
||||
tooltipDiv.style.top = `${y + 20}px`;
|
||||
|
||||
// move tooltip away from edge as user approaches right side
|
||||
const shiftLeftAmount = Math.round(
|
||||
tooltipDiv.clientWidth * 1.2 * (x / document.body.clientWidth)
|
||||
);
|
||||
|
||||
tooltipDiv.style.left = `${x + 40 - shiftLeftAmount}px`;
|
||||
tooltipDiv.style.top = `${y + 40}px`;
|
||||
tooltipDiv.style.opacity = "1";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue