Skip to content

Allow tooltips to follow the mouse when in popover mode - #39

Open
Pjaerr wants to merge 1 commit into
mainfrom
follow-mouse
Open

Allow tooltips to follow the mouse when in popover mode#39
Pjaerr wants to merge 1 commit into
mainfrom
follow-mouse

Conversation

@Pjaerr

@Pjaerr Pjaerr commented Jul 10, 2026

Copy link
Copy Markdown
Member

Adds a new @followMouse arg that, when enabled alongside @usePopover, will make the tooltip follow the mouse, anchored to the axis that matches the edge it is on (ie. if the tooltip is positioned at the top edge of the tooltipper, then it will be moved along the X axis, and if it is positioned at the left edge of the tooltipper, then it will be moved along the Y axis).

@Pjaerr
Pjaerr requested a review from amk221 July 10, 2026 14:59
@Pjaerr Pjaerr self-assigned this Jul 10, 2026
@Pjaerr

Pjaerr commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

馃憢 @amk221 I still need to add tests but raising for you to take an initial look whenever you get a moment

Comment thread src/utils/get-side.js Outdated
@amk221

amk221 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Looks good thank you!

  • the new if statement in tooltipStyle should refer to shouldFollowMouse

  • as you mentioned, couple more scenarios needed - one that comes to mind is that it stops if the mouse is over the tooltip

cheers

Comment on lines 55 to +66
get tooltipStyle() {
const [x, y] = this.tooltipCoords;
if (!this.args.usePopover) {
const [x, y] = this.tooltipCoords;

return htmlSafe(`top: ${y}px; left: ${x}px`);
return htmlSafe(`top: ${y}px; left: ${x}px`);
}

if (this.shouldFollowMouse) {
return htmlSafe(`translate: var(--offset-x, 0px) var(--offset-y, 0px)`);
}

return '';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of this, but also not a fan of what it would take to not apply this.tooltipStyle in the template.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as in I just want to return null from the getter 馃槀

@Pjaerr
Pjaerr requested review from amk221 and removed request for amk221 July 27, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants