feat: box layout and resize + anchor observer primitives - #10558
feat: box layout and resize + anchor observer primitives#10558nwidynski wants to merge 1 commit into
Conversation
|
@LFDanLu This is the PR to look at for floating-ui, although it also addresses various other issues, like the ones coming from |
| * Returns the bounding rectangle of this target in frame coordinate space. | ||
| * Similar to `element.getBoundingClientRect()`, but normalized across engines. | ||
| */ | ||
| public get boundingRect(): DOMRect { |
There was a problem hiding this comment.
getBoundingClientRect returns values with transforms applied. Should the values in here be converted into the same coordinate space? (i.e. * scaleX, * scaleY)
There was a problem hiding this comment.
You mean the computed style values, right? If so, then yeah, we probably should.
| this.update(); | ||
| }); | ||
|
|
||
| super.disconnect(); |
There was a problem hiding this comment.
This sets changedAt to 0 here, is that right? Reconnection wouldn't happen in the next frame.
There was a problem hiding this comment.
Ah no, good catch! I'm still unsure about the rAF loop in general. It was intended as a performance measure so the browser wouldn't have to perform layout on the sentinels each frame, but I'm unsure whether that's actually a net benefit. Will need benchmarks.
| * Similar to `element.getBoundingClientRect()`, but intersected with all ancestors. | ||
| */ | ||
| public get visibleRect(): DOMRect { | ||
| throw new Error('Not implemented yet.'); |
There was a problem hiding this comment.
Kinda. I don't have a great use case for it yet, besides window scrolling in virtualizer, so it just satisfies the type for now. IIRC it wasn't added in virtualizer because walking the tree would be too costly.
Closes no issues directly, because this PR is intentionally limited to additions only. Migrating call sites to the new utilities and signatures is to be done in chore follow-ups, because it would otherwise be rather hard to review what changed here.
Disclaimer: This PR is tightly related to #10556! Unfortunately Github doesn't allow for Stacks to be built across forks, so we have to do with this :/
From a high-level, this PR fixes various issues with layout precision and lays the groundwork for an alternative to floating-ui. The primary file to look at is
layout.ts, which features a short description.Will close #7142, #10036, #10131, #9318 and more.
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: