Skip to content

Commit

Permalink
Fix tooltips position whilst page is scrolled
Browse files Browse the repository at this point in the history
  • Loading branch information
IRHM committed May 8, 2023
1 parent 91e1e87 commit 4b6bee9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/actions/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default function tooltip(node: HTMLElement, opts: ToolTipOptions) {
tooltip.innerHTML = text;
const nrect = node.getBoundingClientRect();
const trect = tooltip.getBoundingClientRect();
nrect.y += window.scrollY; // Add scrollY to node dom rect so tooltip shows correcting when page is scrolled down
if (pos === "left") {
tooltip.style.left = `${nrect.x - trect.width - 10}px`;
tooltip.style.top = `${nrect.y + trect.height / 2 - 10}px`;
Expand Down

0 comments on commit 4b6bee9

Please sign in to comment.