question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Core] Add `relative` modifier

See original GitHub issue

Hey, thanks for creating the library

I’m suggesting to add a relative modifier to the library, which let’s you align tooltips relative to element from another context The use-case for this is aligning tooltips within iframes or on canvas (where you know the relative coordinates upfront)

Here’s the modifier code:

const relative = {
  name: 'relative',
  fn: ({ x, y, element }) => {
    const rect = element.getBoundingClientRect()
    return {
      x: rect.left + x,
      y: rect.top + y
    }
  }
}

without relative modifier

https://user-images.githubusercontent.com/10400064/169694677-a8c88c8e-f263-47f7-9327-d2311df8731d.mov

with relative modifier

https://user-images.githubusercontent.com/10400064/169694680-fa4b3cb5-36ca-4f42-aaa8-bf0064b27a7f.mov

you can already achieve similar functionality by using virtual elements

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
talldancommented, Jul 14, 2022

Just thought I’d mention that the project I work on had a very similar custom middleware solution for offsetting an iframe to the one shown in the issue description.

A problem I encountered is that custom middleware that provides an offset doesn’t seem compatible with floating ui’s shift middleware (when used with limitShift). That seems to expect any offsets to be provided through middleware data: https://github.com/floating-ui/floating-ui/blob/77c4b27a8096cafe06e58b2c7592317d6d3a3aea/packages/core/src/middleware/shift.ts#L203-L212

0reactions
talldancommented, Jul 19, 2022

I see. My mistake is that I didn’t realise that some middleware (like flip) has a different definition of main/cross axis. Flip is the definition I saw first and I ran with that. 🤦

I was finding it a bit confusing, but now it makes a lot more sense. Thanks for clarifying.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modifier - Android Developers
A Modifier that can add padding to position the content according to specified distances ... the alignment line relative to which the padding...
Read more >
net - How to get relative path from absolute path - Stack Overflow
NET Core 2.0 has Path.GetRelativePath which can be used like so: var relativePath = Path.GetRelativePath( @"C:\Program Files\Dummy Folder\MyProgram ...
Read more >
Coding Corner: How to appropriately apply modifiers LT, RT ...
The MPFS Relative Value File shows a 1 modifier indicator in the BILAT SURG column for this code; therefore, modifier 50 may be...
Read more >
A library for writing Ember modifiers - GitHub
ember-modifier. This addon provides an API for authoring element modifiers in Ember. It mirrors Ember's helper API, with variations for writing both simple ......
Read more >
ASP.NET Core Razor components - Microsoft Learn
Optionally, components can be added to the NavMenu component so that a ... However, C# assumes the private access modifier when no access ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found