Skip to content

feat: add v4's float effect (follow mouse position) #861

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

Merged
merged 20 commits into from
Dec 21, 2022

Conversation

gabrieljablonski
Copy link
Member

@gabrieljablonski gabrieljablonski commented Dec 15, 2022

TODO

  • Create and handle float: boolean prop to add mousemove event listener (is there really a need for an effect: 'solid' | 'float' prop?)
  • Handle offset according to place value
  • handleShowTooltip() should also use virtual element when float is true

@danielbarion
Copy link
Member

I believe we really need to give the option to use a fixed tooltip or this one, both situations are for different use cases.

Also, do you know if for float option is there a way to not let the arrow corner go out of the tooltip container like the image?

image

The implementation looks good to me.

@danielbarion danielbarion changed the title Add v4's float effect (follow mouse position) feat: add v4's float effect (follow mouse position) Dec 16, 2022
@gabrieljablonski
Copy link
Member Author

I believe we really need to give the option to use a fixed tooltip or this one, both situations are for different use cases.

For sure. I just meant instead of v4's effect prop to select which mode to use, we could simply add a boolean float or followMouse to enable this mode.

Also, do you know if for float option is there a way to not let the arrow corner go out of the tooltip container like the image?

It'll probably not be too hard to add a minimum distance between the tooltip border and the arrow position.

@danielbarion danielbarion marked this pull request as ready for review December 20, 2022 15:14
- [ ] disableInternalStyle - **Deprecated** | in V5 -> CSS will be a separate file and can be imported or not
- [x] `children`
- [x] `place` - also available on anchor element as `data-tooltip-place`
- [ ] `type` - use `variant`. also available on anchor element as `data-tooltip-variant`
Copy link
Member Author

Choose a reason for hiding this comment

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

Having both the empty brackets [ ] and **Deprecated** seemed redundant.

Comment on lines 236 to 249
if (float) {
if (lastFloatPosition) {
/*
Without this, changes to `content`, `place`, `offset`, ..., will only
trigger a position calculation after a `mousemove` event.

To see why this matters, comment this line, run `yarn dev` and click the
"Hover me!" anchor.
*/
handleTooltipPosition(lastFloatPosition)
}
// if `float` is set, override regular positioning
return () => null
}
Copy link
Member Author

Choose a reason for hiding this comment

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

For future reference!

@gabrieljablonski gabrieljablonski merged commit c875241 into master Dec 21, 2022
@gabrieljablonski gabrieljablonski deleted the tooltip-effect-float branch December 21, 2022 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants