Expand description
Motion primitives that respect the user’s reduced-motion preference.
The layers build on each other:
CubicBezierandEasingname curves;Springsolves physical motion in closed form;MotionSpecpairs a curve with a duration and delay;Interpolatemoves a value between two states;Keyframestakes a value through named stops rather than straight across;Transitionanimates a value whose target can change mid-flight, carrying the speed it already had across a retarget;VelocityTrackermeasures how fast a gesture is moving, which is whatflick,rubber_bandandTransition::releaseneed;ScrollLinkreads a scroll offset as a progress, which is motion with no clock in it at all;Presencekeeps an element alive long enough to animate out, and plays a phase backwards from where it had got to when the other cancels it;Staggerspreads one specification across a group, forwards or in reverse;Sequenceruns specifications one after another and knows how long they take together;Flipping::flipslides an element from where it was to where it is, andFlipping::flip_sizeadditionally resizes it;Animated::animate_inputs any of this on an element in one call, which is the layer most components should reach for.
Motion never changes what a surface publishes. A slide, a press response and a counting number are all painted over a layout, a hit target and a semantic tree that already report the settled value.
Decorative motion built on GPUI’s with_animation already stops when
gpui::App::reduce_motion is set. Transition::animate and
Presence::animate honor the same preference by finishing immediately.
Structs§
- Cubic
Bezier - A CSS-compatible cubic-bezier curve, evaluated in pure Rust so a curve can be asserted without a window.
- Flip
- A handle to one element’s slide, keyed by semantic id.
- Flipped
- An element painted at an offset from where layout put it, and optionally at a size on its way to the size layout would give it.
- Keyframe
- One stop on the path: the value, where along the run it is reached, and optionally the curve it is reached on.
- Keyframes
- A value that passes through named stops rather than travelling straight from one end to the other.
- Motion
Spec - A curve with a duration and a delay: everything one animation needs, taken from the token document rather than written beside the element.
- Presence
- An element’s arrival and departure, either of which can be cancelled by the other while it is still running.
- Scroll
Link - Scroll offsets mapped onto progress from 0 to 1.
- Sequence
- A chain of specifications, each starting when the one before it has finished.
- Spring
- A damped spring, solved in closed form so a position is a function of time rather than of how many frames happened to be delivered.
- Stagger
- Delays each item in a list so a group animates as a wave.
- Transition
- A value that animates toward whatever it is last told to be.
- Velocity
- How fast a gesture is moving, in pixels a second on each axis.
- Velocity
Tracker - The speed and direction of a pointer, measured over a short trailing window.
Enums§
- Activity
- The shape of a piece of work that is currently under way.
- Easing
- A curve named by role rather than by control points.
- Entrance
- How an element arrives.
- Flick
- Which way a flick went.
- Phase
- Where an element is in its arrival or departure.
Constants§
- ROW_
STAGGER_ CAP - The longest a row wave can last, whatever the row count.
- VELOCITY_
WINDOW - How far back a velocity is measured by default.
Traits§
- Animated
- A token-backed entrance in one call.
- Animation
Ext - An extension trait for adding the animation wrapper to both Elements and Components
- Flipping
- Slides an element from where it was to where it is.
- Interpolate
- A value an animation can move through.
Functions§
- breathe
- Breathes an element, for work that has nothing to report yet.
- breathing_
dot - A dot that breathes, for a place with room for a mark but not a glyph.
- content_
in - The arrival a block of content makes when it replaces what was there.
- dialog
- How a modal arrives: slower, because it is taking the page over.
- dialog_
arrival - How a modal arrives when it should arrive with weight: on the smooth spring, which keeps moving after a curve of the same length has stopped.
- dialog_
in - The arrival a modal makes: it rises onto the page on a spring, so it arrives with weight rather than simply appearing at full strength.
- entrance
- How a surface that is part of the page arrives.
- fade_in
- Fades
elementin over the entrance specification. - flick
- Whether a gesture that travelled
traveland let go atvelocitywas a flick, and which way it went. - flip
- The slide handle for
id. - gradient_
opacity - The repeating opacity a gradient spinner turns on.
- menu
- How a menu opens: short, because it is answering a click.
- menu_in
- The opening a menu makes: a fade with a small rise.
- pulse_
wave - The repeating wave a loading placeholder breathes on.
- reduce_
motion - Whether the user asked for non-essential motion to be suppressed.
- resize
- How a value that has a position moves to a new one, such as a progress fill or an opening section.
- row_in
- The arrival one row of a menu-shaped list makes.
- rubber_
band - The distance actually shown when a gesture pulls
overscrollpast a boundary. - shared_
flip - The slide handle for
id, kept alive across a handoff between two element trees. - shimmer_
offset - The sweep a loading placeholder’s highlight travels on, as a fraction of the placeholder’s own width.
- spin
- Turns a glyph, for work whose remaining extent is unknown.
- staggered_
phase - The repeating phase for item
indexin a looping group animation, such as a chase or wave loader. - state_
change - How one control moves to a new state: short, because it is answering a pointer that is still on it.
- sweep
- A band travelling across whatever it is placed in, for work of known extent.
- tracked_
ids - The ids the flip global currently retains.
- tracking
- How a control that is being manipulated follows the value: the tight spring, so it feels attached rather than trailing.