Skip to content

A box glides to where layout moves it, and what a moved box holds is clipped where its clipping box is drawn - #10

Merged
explodi merged 2 commits into
mainfrom
glide
Nov 13, 2026
Merged

explodi merged 2 commits into
mainfrom
glide

Conversation

@explodi

@explodi explodi commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Two commits. The first adds a way to animate a layout change; the second fixes a clipping bug that the first exposed but that already hit any translated animation inside a box that clips.

A box glides to where layout moves it

A Box given glideMs is drawn from where it was when layout moves it in its parent, and closes the gap over that many milliseconds, slowing as it arrives (a cubic ease-out), with everything it holds. Until now an animation could only play a token's fixed keyframes, so nothing could follow a move whose size depends on the layout: a tab strip sliding to centre the open tab when the tabs' widths differ, a selection bar running between rows, a marker travelling along a track. Each now costs one React render per change, not one per frame.

  • A move during a glide sets off from where the box is drawn then, so quick presses run on into each other.
  • Only a move in its parent glides. A box appears in place, and a scroll or a move of its parent carries it at once. Layout keeps each box's offset in its parent (Place::inParentX, inParentY, Yoga's own left and top), because its rect moves with every scroll and every sticky shift.
  • Under reduced motion it stands in its new place at once.
  • The pointer meets it where it is drawn: hit testing reads the glide's shift as it reads an animation's.

What a moved box holds is clipped where its clipping box is drawn

Paint offset a node's clip, which is the edge of an ancestor that clips (a Scroll, or overflow: "hidden"), by the node's own accumulated shift. When a box between the clipping ancestor and the node was moved by an animation or a glide, the clip moved with it, though the clipping box hadn't moved. A tag gliding along a strip that clips had its text cut where the strip's edge would have been had the strip glided too, and a row coming in from the left with a translateX animation had its right side cut. The pointer missed what showed, the same way.

Paint now keeps the shift of the nearest box that clips (PaintState::clipDx, clipDy) apart from the node's own, offsets clips by it, and records it for hit testing (PaintedShift::clipDx, clipDy).

Tests

tests/view_test.cpp, 10 new doctests: a gliding box appears in place and owes no frames; a move glides from where the box was drawn (7/8 of the way at half time); it owes frames until it arrives; a move mid-glide sets off from where it is drawn; a move of its parent or a scroll carries it at once; reduced motion jumps; the pointer hits it where it is drawn; and, for the clip, a translated box's content keeps its clipping box's clip (failed before: 150px wide, not 200), and the pointer meets that content inside it (failed before: the hit went to the parent). All 288 C++ and 364 TypeScript tests pass.

Where it's used

XLR8's garage files its parts by category on a rail turned with LB/RB. The rail, its position marker and the selection bar glide; the rows come in on staggered token animations. It runs with this branch vendored while it's reviewed.

https://claude.ai/code/session_015YsDT2R1ktGozfGHLod1JN

A box given `glideMs` is drawn from where it was when layout moves it in
its parent, and closes the gap over that many milliseconds, slowing as it
arrives, with everything it holds. A tab strip slides to centre the open
tab, a selection bar runs between rows, and a position marker travels
along its track, each for one React render rather than one a frame.

- A move during a glide sets off from where the box is drawn then, so
  quick moves run on into each other.
- Only a move in its parent glides: a box appears in place, and a scroll
  or a move of its parent carries it at once. Layout keeps each box's
  offset in its parent (Place::inParentX, inParentY) for this, as its
  rect moves with every scroll.
- Under reduced motion the box stands in its new place at once.
- The pointer meets the box where it is drawn: hit testing reads the
  glide's shift as it reads an animation's.

Each has its doctest in tests/view_test.cpp.

Claude-Session: https://claude.ai/code/session_015YsDT2R1ktGozfGHLod1JN
A box moved by an animation or a glide inside a box that clips carried
the clip of everything it holds along with it: paint offset a
descendant's clip by the descendant's own shift, though the clip is the
edge of the box that clips, which hadn't moved. A tag gliding in a strip
that clips had its text cut where the strip's edge would be had the
strip glided too, and the pointer missed what showed of it.

Paint now keeps the shift of the nearest box that clips (Scroll, or
overflow "hidden") apart from the node's own, and offsets clips by it,
in paint and in what hit testing reads (PaintedShift::clipDx, clipDy).

Each half has its doctest in tests/view_test.cpp.

Claude-Session: https://claude.ai/code/session_015YsDT2R1ktGozfGHLod1JN
@explodi
explodi merged commit 906543d into main Nov 13, 2026
2 checks passed
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