Skip to main content

AnimationSpec

Struct AnimationSpec 

Source
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

Source

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.

Source

pub fn instant(self) -> Self

MotionTokens::duration_instant (default 0 ms).

Source

pub fn fast(self) -> Self

MotionTokens::duration_fast (default 120 ms — tooltip fade, interactive feedback).

Source

pub fn normal(self) -> Self

MotionTokens::duration_normal (default 200 ms — notification slides, generic transitions).

Source

pub fn slow(self) -> Self

MotionTokens::duration_slow (default 300 ms — dialog appearance).

Source

pub fn collapse(self) -> Self

MotionTokens::duration_collapse (default 200 ms — accordion / disclosure expand-collapse).

Source

pub fn sweep(self) -> Self

MotionTokens::duration_indeterminate_sweep (default 900 ms — indeterminate progress sweep, spinner period). Implies looping().

Source

pub fn duration(self, duration: Duration) -> Self

Set the duration explicitly. Prefer the named presets when one fits — they keep the design system honest.

Source

pub fn standard(self) -> Self

MotionTokens::easing_standard (default EaseOut). The Int-UI “single mild ease-out everywhere” curve.

Source

pub fn linear(self) -> Self

Source

pub fn ease_in(self) -> Self

Source

pub fn ease_out(self) -> Self

Source

pub fn ease_in_out(self) -> Self

Source

pub fn easing(self, easing: Easing) -> Self

Source

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.

Source

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.

Source

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).

Source

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)).

Source

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”.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> AnimationSpec

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AnimationSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.