Skip to content

feat(Lightbox): zoom from a thumbnail and back, like Photos - #8231

Closed
vjeux wants to merge 2283 commits into
meta:mainfrom
vjeux:uikit/c24-zoom-transition
Closed

vjeux wants to merge 2283 commits into
meta:mainfrom
vjeux:uikit/c24-zoom-transition

Conversation

@vjeux

@vjeux vjeux commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #8215, and on #8665 and #8676 (gestures for every pointer), which this stack carries. Review only this PR's change: vjeux/astryx@11abd78...a140e96

Why

In Photos, a photo opens by growing out of its thumbnail and closes back into it, so you keep your place in the grid. A Lightbox photo appears and disappears at once, with no link to the thumbnail you tapped.

What led to it

The UIKit-parity work for Astryx (spec:AST-094): UIKit's zoom transition, on the dismissal (#8215), so a photo dragged down lands in its thumbnail.

Options and tradeoffs

  • The browser's View Transitions: built in, but a finger cannot catch one mid-flight, and not every supported browser has them.
  • A copy of the thumbnail animated on the compositor (this PR): works everywhere, a close can start mid-opening, and it stays smooth on a busy page. The cost is 6 KB of gzip JavaScript (96,776 → 102,742 bytes), mostly modules other components share.
  • Finding the thumbnail: the caller names it (experimental.sourceFor), or else the element that opened the viewer, when it shows a picture.

Why this choice

Only a compositor copy can be reversed mid-flight. It all runs inside experimental: without it, a Lightbox keeps its stable behavior (spec:AST-017 FR21). A drag-down close reports onOpenChange(false) when the pointer lifts, as every other close does, and the landing follows the pointer that released it. INV13 in the layer-runtime record belongs to #8186 (the layer runtime's exit copy), which this stack carries: this PR doesn't add it, and the zoom uses its own lifted copy.

Owner question: experimental.sourceFor. It lets a caller name the element a photo grows out of and lands back in, such as one thumbnail in its own grid. Without it, only the element that opened the viewer can be the source, which misses when one button opens a whole gallery. The alternative is to drop the option until a spec names it. My pick: keep it inside experimental.

Owner question: the held close. After a close reports onOpenChange(false), the viewer stays until the photo lands in its thumbnail (on touch, and for a drag down under any pointer), as Photos does, so the photo returns to its place instead of vanishing mid-flight. The alternative is to remove the viewer at once and skip the landing. My pick: keep it, inside experimental.

How to check it

In the "Gallery" story, which passes experimental, on a phone:

  1. Tap a thumbnail: the photo grows out of it.
  2. Tap Close: it shrinks back into its thumbnail.
  3. Drag the photo down and let go: it lands in its thumbnail.
  4. With a mouse, the viewer opens and closes at once, as before, and a drag down lands in the thumbnail too.
  5. With Reduce Motion on, the photo fades in place.

Evidence

Safari on the iOS 26.2 simulator:

main this PR
main: at once grows from the thumbnail

The opening's busy proof judged a window too short to judge: it held no frames of a compositor-only control animation. It now blocks inside the page for 300 ms and holds 17 to 18 control frames in both engines.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review needs:spec-owner-review Current knowledge records await owner approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants