Skip to main content

Animation

Trait Animation 

Source
pub trait Animation<T>: 'static
where T: Animatable,
{ // Required methods fn value(&self) -> &T; fn state(&self) -> AnimationState; fn tick(&mut self, delta: Duration); fn pause(&mut self); fn resume(&mut self); fn cancel(&mut self); fn seek(&mut self, progress: f32); fn finish(&mut self); // Provided methods fn duration(&self) -> Option<Duration> { ... } fn advance(&mut self, delta: Duration) -> Duration { ... } fn retarget(&mut self, _target: &T) -> bool { ... } fn is_active(&self) -> bool { ... } }
Expand description

A stateful source that produces animated values over time.

Required Methods§

Source

fn value(&self) -> &T

Returns the animation’s current value.

Source

fn state(&self) -> AnimationState

Returns the animation’s lifecycle state.

Source

fn tick(&mut self, delta: Duration)

Advances the animation by delta.

Source

fn pause(&mut self)

Pauses a running animation.

Source

fn resume(&mut self)

Resumes a paused animation.

Source

fn cancel(&mut self)

Cancels the animation.

Source

fn seek(&mut self, progress: f32)

Seeks to normalized progress within the animation.

Source

fn finish(&mut self)

Moves the animation to its completed state.

Provided Methods§

Source

fn duration(&self) -> Option<Duration>

Returns the total duration when it is finite and known.

Source

fn advance(&mut self, delta: Duration) -> Duration

Advances the animation and returns any unconsumed duration.

Source

fn retarget(&mut self, _target: &T) -> bool

Attempts to continue the animation toward a new target.

Returns true when the animation supports retargeting.

Source

fn is_active(&self) -> bool

Returns whether the animation is currently running.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> Animation<T> for Hold<T>
where T: Animatable,

Source§

impl<T> Animation<T> for Keyframes<T>
where T: Animatable,

Source§

impl<T> Animation<T> for Parallel<T>
where T: Animatable,

Source§

impl<T> Animation<T> for Sequence<T>
where T: Animatable,

Source§

impl<T> Animation<T> for Spring<T>
where T: Animatable,

Source§

impl<T> Animation<T> for Tween<T>
where T: Animatable,