Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tooltip position calculation #229

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading