This repository was archived by the owner on Nov 9, 2024. It is now read-only.
This repository was archived by the owner on Nov 9, 2024. It is now read-only.
Better support for multiline spans #763
Closed
Description
When using tippy on an element that is split between two lines, the default behavior is something like that:
There was already this issue with a suggestion to use followCursor
.
So when using followCursor: 'initial'
with placement: 'bottom'
the placement is weird (target is hidden) sometimes:
So when using followCursor: 'horizontal'
the offset is wrong:
Is there anything I missed to improve the position of the tooltip?
Metadata
Metadata
Assignees
Labels
No labels
Activity
atomiks commentedon Apr 24, 2020
https://atomiks.github.io/tippyjs/v6/all-props/#inlinepositioning?
philippkuehn commentedon Apr 24, 2020
Yeah, now it’s… different 😅
atomiks commentedon Apr 24, 2020
Yeah... I wanted to work on that for a while but for some reason it never worked fully reliably if the cursor entered the edges. If you can think of a solution please send a PR 😓
atomiks commentedon Apr 25, 2020
For anyone interested in helping develop this feature, as I think it's pretty complex:
You need to be able to choose which rect to use based on two things:
For example:
The cursor entered from the bottom of the left part (the orange rect):
—
top
placement: virtual rect is the green rect above it—
bottom
placement: virtual rect is the orange rect itselfThe cursor entered from the bottom of the very right part (the pink rect):
—
top
placement: virtual rect is the blue one above it—
bottom
placement: virtual rect is the pink rect itselfThe cursor entered from the bottom of the purple rect to the right:
—
top
placement: virtual rect is the green rect, but only if the cursor is to the left of the blue rect—
bottom
placement: virtual rect is the purple rect itselfatomiks commentedon Apr 25, 2020
An alternative:
Detect if the two rects are "disjoined" and use a simpler version of the above, and if they're connected, use the current behavior? 🤔
atomiks commentedon Apr 27, 2020
Install
v6.2.1
and it should work well nowphilippkuehn commentedon Apr 27, 2020
Hey, great! It’s much better! However there is a bug when the cursor comes from the left side. But it’s not always. The first example works as expected. The second doesn’t. 👀
atomiks commentedon Apr 27, 2020
Noo 😢 that's the issue I mentioned haha, but I didn't encounter it this time. I used 1px buffer too, do you have any ideas?
atomiks commentedon Apr 27, 2020
I can't reproduce it myself for example, but I know I encountered this last year when trying to add the feature 👀 Maybe a 2px buffer 😅? Can you try editing
node_modules/tippy.js/dist/tippy.esm.js
with2
instead of the1
in the link above?philippkuehn commentedon Apr 27, 2020
Haha, yeah 2px works for me! 😅
atomiks commentedon Apr 27, 2020
I also use
2px
default forinteractiveBorder
, and haven't had any issues with that since 2017, so hopefully it's a "safe" value. I have no idea why.clientX/Y
from theMouseEvent
wouldn't be within the 1px-buffered bounds of.getClientRects()
(accounting for rounding errors), but anyway...atomiks commentedon Apr 27, 2020
I published
6.2.2
@philippkuehn, let's hope2
is enough or we might need a different solution D:Also it falls back to the old
inlinePositioning
instead of the standard rect so it should be a little bit better in the worst case.1 remaining item