Repository navigation
perf(Text): take a new text's first truncation measurement from the shared observer #10668
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [perf] Truncating Text and Heading take a newly mounted element's first measurement from the shared resize observer's first notification, after the browser's own layout, instead of forcing a layout pass after each commit. Pages and windowed tables that mount many truncating texts commit faster; the tooltip behaves as before. | ||
|
|
||
| @humbertovirtudes |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,8 @@ | |
| /** | ||
| * @file sharedResizeObserver.ts | ||
| * @input ResizeObserver API | ||
| * @output Exports observeResize / unobserveResize for shared observation | ||
| * @output Exports observeResize / unobserveResize for shared observation, and | ||
| * the internal isResizeObserved | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking: this header is now 17 lines, past the "about 12 lines" the source-comment convention sets for |
||
| * @position Utility; consumed by useTruncation, useOverflow, and any component | ||
| * that needs resize observation without creating per-instance observers | ||
| * | ||
|
|
@@ -52,6 +53,11 @@ function getObserver(): ResizeObserver | null { | |
| return observer; | ||
| } | ||
|
|
||
| /** Whether the shared observer already watches `element`. Internal. */ | ||
| export function isResizeObserved(element: Element): boolean { | ||
| return callbacks.has(element); | ||
| } | ||
|
|
||
| /** | ||
| * Observe an element's size via a shared ResizeObserver singleton. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking: "Observe via the shared singleton, if available." restates the
typeof ResizeObserverbranch and theobserveResizecall below it. Dropping it lets the comment start with its reason: