Skip to content

fix(element): withhold paint until a pixel translate actually settles - #122

Draft
DouweBos wants to merge 1 commit into
mainfrom
douwe/withhold-paint-until-translate-settles
Draft

fix(element): withhold paint until a pixel translate actually settles#122
DouweBos wants to merge 1 commit into
mainfrom
douwe/withhold-paint-until-translate-settles

Conversation

@DouweBos

Copy link
Copy Markdown
Contributor

What

LightningViewElement withholds paint until a node's first layout resolves, and isTranslateSettled extends that so a pixel translate isn't revealed at its pre-transform origin. The reveal was bounded to exactly one extra layout pass:

if (this._paintWithheld && (hadLayout || isTranslateSettled(...)))

hadLayout || short-circuits the check, so the second layout reveals unconditionally. A translate that folds into the position later than that — deeper in the async flex tree — still paints the node at its base position for a frame.

The reveal now waits for isTranslateSettled to actually return true, bounded by MAX_UNSETTLED_LAYOUTS so a translate the heuristic can't detect (percentage translates, right/bottom anchoring) still can't strand the node invisible.

Why

Found while tracking down a drawer in the Plex RN client that is laid out on screen and translated off: at mount it flashed open for a frame before the translate landed.

Tests

Two cases added to LightningViewElement.spec.ts. Both fail on main for the right reason — the node reveals on the second layout pass while still unsettled:

  • stays withheld while a pixel translate takes more than one layout to settle
  • reveals a never-settling translate rather than stranding it invisible

Full package suite green (307 tests), tsc --noEmit and oxlint clean.

Note on formatting

Left the touched files as-committed rather than running oxfmt — the repo's committed formatting predates oxfmt 0.45, so --check already fails on 5 files in src/element/ on main. Running it here would have added ~190 lines of unrelated churn. Worth a separate formatting pass.

The withheld-paint reveal was bounded to one extra layout pass, so a
translate that folds into the position later still painted the node at its
untransformed origin for a frame. Wait for isTranslateSettled, bounded by a
pass count so an undetectable translate can't strand the node invisible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant