Skip to content

feat(viewer): a photo flies out of the spot it was shown in, and back - #28

Merged
adammharris merged 2 commits into
mainfrom
cc/practical-pasteur-evqtf1
Nov 18, 2026
Merged

adammharris merged 2 commits into
mainfrom
cc/practical-pasteur-evqtf1

Conversation

@adammharris

@adammharris adammharris commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

What

The photo viewer now opens and closes with motion. It already had a drag-down dismissal, but opening it, its Close button and Escape had no animation. A host can now say where a photo was on screen before it opened, and the photo flies to and from that spot.

  • Spot (exported, also in the prelude): a box on the screen in the window's CSS pixels, either Spot::rect(x, y, w, h) for a thumbnail or Spot::point(x, y) for where a finger pressed. A point is a spot with no size, so the photo grows out of it.
  • Photo::from(spot): optional, and set per photo.
    • On open, the photo flies out of the spot to where it rests while the black fades in.
    • On close it flies back into the spot of the photo shown at that moment. This applies to the Close button, Escape, and a drag down past the threshold; in the drag case the flight starts from wherever the finger left the photo.
    • With no spot, the photo fades in while growing slightly where it rests, and fades out while shrinking where it is. The drag-down-without-a-spot behaviour is unchanged.
  • While it flies, a photo with a known size is drawn object-fit: cover inside its moving box. A square thumbnail therefore opens into the full photo the way a phone's Photos app does.
  • Closing order: when asked to close, the viewer plays its exit first and then calls onclose. A page that sets open = false on its own still closes at once.

Timing

Flights run in Rust on the viewer's own frames, the same way the drag-down and the slide do. That's because the flight's start point is dynamic (where the finger let go), and onclose has to fire when the flight ends.

  • Durations come from the theme. Motion gains a travel field: 300ms for unit, 400ms for Soft, 160ms for Sharp. A fade without a spot uses enter and exit.
  • New helpers Theme::travel_ms and Theme::enter_ms sit beside exit_ms. All return 0 under MotionSetting::Reduced or cell density, and the viewer then opens and closes at once.
  • The curve is unit's own cubic-bezier(0.2, 0, 0, 1), evaluated in Rust.

Motion gains a public field, so code that builds a Motion with a struct literal needs a travel. Diaryx builds its theme with ..Theme::soft(), so it isn't affected.

Gallery

Photos opened from the Photos grid fly out of the point where they were pressed. "View Photos…" has no spot, so it fades.

Tests

  • In zoom.rs: a flight's path and fade over time, a zero-length flight, a spot placed on the stage, and where a dragged-down photo is actually drawn.
  • In Blitz, with motion on:
    • tapped open, the photo starts small near the tap and comes to rest fitted;
    • Close and a drag down each end near the tapped spot before the viewer is gone;
    • opened by the button, it grows where it rests, and Escape fades it out.
  • The existing viewer tests run still (reduced motion) and pass unchanged.

All of the ship ci lanes pass locally: fmt, clippy (native and wasm), tests light and dark, and docs.

A Photo may say where it was on the screen before the viewer opened it
(Photo::from, a Spot: a thumbnail's box, or the point a finger pressed).
The viewer flies it out of that spot to fill the window as it opens, and
back into it as it closes, by its button, Escape or a drag down, as a
phone's Photos app does. A photo with no spot fades in growing a little
where it rests, and fades out shrinking where it is.

Asked to close, the viewer goes first and then calls onclose. The flights
are timed in Rust on the viewer's own frames, as its drag down is, and
take the theme's motion: a new Motion::travel for a flight, enter and
exit for a fade, none where less motion is asked for.

The gallery's photos fly out of where they were pressed.
@adammharris
adammharris force-pushed the cc/practical-pasteur-evqtf1 branch from 66e1363 to 827571c Compare November 18, 2026 03:02
@adammharris
adammharris merged commit 99fd711 into main Nov 18, 2026
7 checks passed
@adammharris
adammharris deleted the cc/practical-pasteur-evqtf1 branch November 18, 2026 03:03
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