Skip to content
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
@philippkuehn

Description

@philippkuehn

When using tippy on an element that is split between two lines, the default behavior is something like that:

fail1

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:

fail2

So when using followCursor: 'horizontal' the offset is wrong:

fail3

Is there anything I missed to improve the position of the tooltip?

Activity

philippkuehn

philippkuehn commented on Apr 24, 2020

@philippkuehn
Author

Yeah, now it’s… different 😅

fail4

atomiks

atomiks commented on Apr 24, 2020

@atomiks
Owner

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

atomiks commented on Apr 25, 2020

@atomiks
Owner

For anyone interested in helping develop this feature, as I think it's pretty complex:

demo of multiple rects

You need to be able to choose which rect to use based on two things:

  1. Where the cursor entered from
  2. The placement of the tippy

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 itself

  • The 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 itself

  • The 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 itself

atomiks

atomiks commented on Apr 25, 2020

@atomiks
Owner

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

atomiks commented on Apr 27, 2020

@atomiks
Owner

Install v6.2.1 and it should work well now

philippkuehn

philippkuehn commented on Apr 27, 2020

@philippkuehn
Author

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. 👀

Apr-27-2020 09-10-50

atomiks

atomiks commented on Apr 27, 2020

@atomiks
Owner

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

atomiks commented on Apr 27, 2020

@atomiks
Owner

demo

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 with 2 instead of the 1 in the link above?

philippkuehn

philippkuehn commented on Apr 27, 2020

@philippkuehn
Author

Haha, yeah 2px works for me! 😅

atomiks

atomiks commented on Apr 27, 2020

@atomiks
Owner

I also use 2px default for interactiveBorder, 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 the MouseEvent wouldn't be within the 1px-buffered bounds of .getClientRects() (accounting for rounding errors), but anyway...

atomiks

atomiks commented on Apr 27, 2020

@atomiks
Owner

I published 6.2.2 @philippkuehn, let's hope 2 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

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @philippkuehn@atomiks

      Issue actions

        Better support for multiline spans · Issue #763 · atomiks/tippyjs