Skip to content

Viewport Transitions

Every viewport helper has an async twin that eases over a duration - SetCenterAsync, FitViewAsync, FitBoundsAsync, ZoomToAsync and SetViewportAsync. Jumping between two far-apart parts of a graph loses the reader; a short eased transition tells them which way they travelled.

settled
Start
Fan out
Fan out
Join
Finish
Arrow keys move the view, Home shows the whole flow.
Drag the pane mid-flight: the drag wins.
bit Blow

Try it

  • Drag Duration to choose how long each move takes; at instant every button jumps.
  • Fly to Start and Fly to Finish glide to the two ends of the graph and zoom to 120%; Frame the fan-out fits the two middle nodes, and Fit all the whole graph.
  • Zoom to 200% zooms about the middle of the pane without panning.
  • Bookmark this view remembers where you are; pan away, then Back to bookmark glides back to it.
  • Watch the readout at the end of the toolbar: it says moving with the zoom of every frame while a transition runs, and settled once it ends.
  • Start a long transition, then drag the pane before it lands: the transition stops where it got to and the drag takes over. Pressing another button mid-flight starts the new move from there.
  • Set Motion to Reduce: every button jumps whatever the duration, and the animated edges keep their dashes but stop marching. Always animate ignores the operating system's setting.

How it works

  • SetCenterAsync(x, y, zoom, durationMs) centres a flow point, here the middle of a node from GetNode(id).GetRect().
  • FitBoundsAsync(rect, padding, durationMs) fits any flow-space BlowRect - the box round the two middle nodes - and FitViewAsync(options) fits nodes, taking its duration from BlowFitViewOptions.Duration.
  • ZoomToAsync(zoom, durationMs) sets an absolute zoom about the pane centre. Every helper clamps to MinZoom and MaxZoom - lowered to 0.1 here so the whole graph fits.
  • GetViewport() reads the current BlowViewport, and SetViewportAsync(viewport, durationMs) eases back to a saved one.
  • Each has a synchronous twin - SetCenter, FitBounds, FitView, ZoomTo, SetViewport - that never animates; a duration of 0 makes the async ones apply at once too.
  • A new request cancels the one in flight, so the last one wins; a user pan, pinch or scroll abandons it, since a transition still easing to its old target would fight the pointer.
  • OnMoveStart and OnMoveEnd bracket a transition as they do a gesture, and OnMove reports every frame in between.
  • ReducedMotion (default BlowReducedMotion.System) follows the operating system's reduce-motion setting; Always and Never override it, and ReducesMotion says which is in force.
An unhandled error has occurred. Reload 🗙