Skip to content

Commit

Permalink
fix: tooltip position calculation (#229)
Browse files Browse the repository at this point in the history
Co-authored-by: denis-vlasov <[email protected]>
  • Loading branch information
wd055 and denis-vlasov authored Nov 5, 2024
1 parent d7d2ff2 commit 26876d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/YagrCore/plugins/tooltip/placement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default function (
// anchor's bounding rect. If we are working in the context of position:
// absolute, then we will need to add the window's scroll position as well.
const maxOffset = document.body[primary.bodyScroll] - window[primary.inner];
const scrollOffset = Math.min(window[primary.scrollOffset] as unknown as number, maxOffset);
const scrollOffset = Math.max(Math.min(window[primary.scrollOffset] as unknown as number, maxOffset), 0);

const boundPrimaryPos = (pos: number) => {
return Math.max(
Expand Down Expand Up @@ -185,7 +185,7 @@ export default function (

// Set the position of the popup element along the secondary axis.
const maxSecondaryOffset = document.body[secondary.bodyScroll] - window[secondary.inner];
const secondaryScrollOffset = Math.min(window[secondary.scrollOffset] as unknown as number, maxSecondaryOffset);
const secondaryScrollOffset = Math.max(Math.min(window[secondary.scrollOffset] as unknown as number, maxSecondaryOffset), 0);

elem.style[secondary.before] = px(
secondaryScrollOffset + boundSecondaryPos(anchorRect[secondary.before] - secondaryMarginBefore),
Expand Down

0 comments on commit 26876d7

Please sign in to comment.