pub struct AnimationSpec { /* private fields */ }Expand description
A fluent specification for animating a Signal<f32>.
Cheap to clone (one MotionTokens, a few primitives). Built via
BuildContext::animate
at widget build time, then captured into event-handler closures
that drive animations.
Implementations§
Source§impl AnimationSpec
impl AnimationSpec
Sourcepub fn from_motion(motion: MotionTokens, reduced_motion: bool) -> Self
pub fn from_motion(motion: MotionTokens, reduced_motion: bool) -> Self
Build a default spec (duration_normal + easing_standard).
Callers normally use BuildContext::animate instead, which
wires in the platform reduced-motion preference.
Sourcepub fn fast(self) -> Self
pub fn fast(self) -> Self
MotionTokens::duration_fast (default 120 ms — tooltip fade,
interactive feedback).
Sourcepub fn normal(self) -> Self
pub fn normal(self) -> Self
MotionTokens::duration_normal (default 200 ms — notification
slides, generic transitions).
Sourcepub fn collapse(self) -> Self
pub fn collapse(self) -> Self
MotionTokens::duration_collapse (default 200 ms — accordion /
disclosure expand-collapse).
Sourcepub fn sweep(self) -> Self
pub fn sweep(self) -> Self
MotionTokens::duration_indeterminate_sweep (default 900 ms —
indeterminate progress sweep, spinner period). Implies
looping().
Sourcepub fn duration(self, duration: Duration) -> Self
pub fn duration(self, duration: Duration) -> Self
Set the duration explicitly. Prefer the named presets when one fits — they keep the design system honest.
Sourcepub fn standard(self) -> Self
pub fn standard(self) -> Self
MotionTokens::easing_standard (default EaseOut). The Int-UI
“single mild ease-out everywhere” curve.
pub fn linear(self) -> Self
pub fn ease_in(self) -> Self
pub fn ease_out(self) -> Self
pub fn ease_in_out(self) -> Self
pub fn easing(self, easing: Easing) -> Self
Sourcepub fn cubic_bezier(self, x1: f32, y1: f32, x2: f32, y2: f32) -> Self
pub fn cubic_bezier(self, x1: f32, y1: f32, x2: f32, y2: f32) -> Self
A CSS cubic-bezier(x1, y1, x2, y2) curve — the general easing
escape hatch for design-language motion specs (Material 3, Fluent)
that don’t reduce to the named curves.
Sourcepub fn m3_emphasized(self) -> Self
pub fn m3_emphasized(self) -> Self
Material 3 “emphasized” curve — cubic-bezier(0.2, 0.0, 0.0, 1.0).
The standard M3 enter/exit feel.
Sourcepub fn looping(self) -> Self
pub fn looping(self) -> Self
Switch to looping mode. Sets a sub-perceptual epsilon (1/255)
and a 60 Hz frame interval only if not already overridden,
so a continuous bar / spinner advances once per vsync on a
60 Hz panel without forcing higher-refresh displays into
extra Signal::set calls (==-equal values short-circuit).
Sourcepub fn frame_interval(self, interval: Duration) -> Self
pub fn frame_interval(self, interval: Duration) -> Self
Throttle scheduler ticks to at most one per interval. Use to
drop a 60 Hz signal animation to 15-30 Hz when the eye can’t
resolve the difference and every doubled frame costs a wgpu
submit (e.g. ProgressBar::indeterminate’s wide sweep, set to
15 Hz via Duration::from_millis(66)).
Sourcepub fn epsilon(self, epsilon: f32) -> Self
pub fn epsilon(self, epsilon: f32) -> Self
Per-tick quantization. Skip Signal::set(value) when the new
value differs from the last set value by less than epsilon.
0.0 (the one-shot default) means “set every tick”.
Sourcepub fn to(&self, signal: &Signal<f32>, target: f32)
pub fn to(&self, signal: &Signal<f32>, target: f32)
Animate signal to target using this spec. Returns
immediately; the scheduler drives the tween.
Does NOT honor prefers_reduced_motion; use
to_or_snap for that.
Sourcepub fn to_or_snap(&self, signal: &Signal<f32>, target: f32)
pub fn to_or_snap(&self, signal: &Signal<f32>, target: f32)
Animate to target, but if the user prefers reduced motion
(snapshot at build time), snap directly to target instead of
tweening. This is the right default for one-shot UI tweens
(toggle knob, accordion collapse, fade).
For continuous looping animations, prefer gating the call site (don’t start the loop at all under reduced motion) — snapping a loop to its end value just stops it on the wrong frame.
Sourcepub fn reduced_motion(&self) -> bool
pub fn reduced_motion(&self) -> bool
Whether the captured platform preference is for reduced motion.
Use as a gate before kicking off a continuous looping animation
(if !spec.reduced_motion() { spec.to(&signal, 1.0); }).
Trait Implementations§
Source§impl Clone for AnimationSpec
impl Clone for AnimationSpec
Source§fn clone(&self) -> AnimationSpec
fn clone(&self) -> AnimationSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more