From 04998cc50204b5d4bf9b54a1d2112285b8b1c4ff Mon Sep 17 00:00:00 2001 From: IRHM <37304121+IRHM@users.noreply.github.com> Date: Mon, 8 May 2023 15:01:51 +0100 Subject: [PATCH] Fix tooltips position whilst page is scrolled --- src/lib/actions/tooltip.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/actions/tooltip.ts b/src/lib/actions/tooltip.ts index 8c60d9bc..186a6821 100644 --- a/src/lib/actions/tooltip.ts +++ b/src/lib/actions/tooltip.ts @@ -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`;