This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
[Core] Collidables #1440
Comments
The only solution is using I think this problem is hard to solve and I'm not sure how to even start on the "holes" thing. |
Maybe I misunderstood the problem, but here are my immediate thoughts: Ideally, the DOM would provide a I will note that at the point where mutual positioning constraints come into play, this massively expands the scope of this library into something like autolayout. |
I believe there are two algorithms for this — one easy and one hard. The easy algorithm is already used to detect a clipping boundary. It would be the area of the visible viewport subtracting "fixed"/"sticky" floating elements that are not controlled by Floating UI, but don't really act like "holes" because they're at the edges of the boundary. These are UI elements like a sticky navbar or sidebar. The hard algorithm is detecting actual "holes" anywhere inside the boundary, where the holes could be other floating elements controlled by Floating UI itself. Forgot to post this here when I first saw it, but I imagine the hard algorithm would generalize the problem and result in positioning like this: |
I decided to actually try to solve this and it took me 1 hour to get this far. I've got some logic working for both Screen.Recording.2023-03-26.at.8.01.27.pm.movThere are some remaining problems:
|
Do you think CSS grids could help? We could draw a grid on top of the page and position the cells to cover the holes, then you could position each tooltip in a cell and have it positioned by grid |
The CSS grid solution sounds interesting, but I don't think it helps with needing to coordinate updates between multiple floating elements when they need to avoid each other. Further, positioning is granular to the pixel, and the grid solution may not be suitable for that. Right now all floating elements can be updated independently of one another and don't need coordination, so we need some kind of system for that. |
I've split this into two separate issues:
|
does anyone know of an alternative library that does exactly what's described here in the issue? my use case would be showing multiple popovers simultaneously without them overlapping, while avoiding certain other elements on the page. |
@rbozan can you show an example of how the popovers are laid out? Would you prefer them to be laid out like a flexbox (coordination), or can they be arbitrarily positioned, as long as there's no overlapping, where popovers that were opened first (or positioned first) take precedence? The latter (this issue) is likely going to be shipped in a week once I get all the edge cases working correctly. |
Thanks for the reply. Indeed it would be the latter. After some research I did choose d3 and their force directed graph but I'll gladly use something simpler for my use case. |
@atomiks hi 👋 has there been any movement on the collidables feature? |
Not really. I think I'll most likely release a basic version of the feature that covers some useful cases, but won't be "complete" (especially including #2268). Can I ask what you're looking to use it for? This will help me understand the popular use cases more. |
One use case that isn't outlined here yet is the new WCAG 2.2 requirement to not obscure elements that receive focus. It would be nice if floating-ui could help us avoid overlaying floating ui elements over elements that currently have focus. I went into greater detail in #2601 without realizing it's highly related to this here. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Expands on #1381
There have been feature requests related to collision detection of other floating elements, not just a surrounding boundaries. To do this it looks like we have to think of boundaries as a polygon with "holes", the holes represent other arbitrary elements to detectOverflow to, not just a surrounding rectangle boundary.
A picture is worth a thousand words:
The holes represent other elements "eating" into the main boundary.
Right now you can either use
padding
in theshift
/flip
modifiers (only works for static things like a sticky header or navbar), or let the floating element overlap those other floating elements with a higher z-index.The text was updated successfully, but these errors were encountered: