Skip to main content

AnimationController

Struct AnimationController 

Source
pub struct AnimationController { /* private fields */ }
Expand description

The shared animation layer — physics, curves, driver — see frus_core::animation. Re-exported here so applications can reach it through frus_widgets without depending on frus-core directly. Drives a value bounded to [lower, upper] through a pluggable simulation.

Implementations§

Source§

impl AnimationController

Source

pub fn new(lower: f32, upper: f32) -> AnimationController

A controller bounding its value to [lower, upper], starting at lower.

Source

pub fn unit() -> AnimationController

The standard controller over [0, 1].

Source

pub fn bounds(&self) -> (f32, f32)

The controller’s [lower, upper] bounds.

Source

pub fn value(&self) -> f32

The current value.

Source

pub fn velocity(&self) -> f32

The current velocity, in units per second.

Source

pub fn status(&self) -> Status

The current status.

Source

pub fn is_animating(&self) -> bool

true while a simulation is running, meaning a frame is needed.

Source

pub fn set_value(&mut self, value: f32)

Sets the value immediately, with no animation, and updates the status.

Source

pub fn reset(&mut self)

Puts the value back to the lower bound, unanimated (set_value(lower)).

Source

pub fn stop(&mut self)

Stops any animation, a AnimationController::repeat loop included, and freezes the current value.

Source

pub fn forward(&mut self, duration: f32, curve: Curve)

Animates to the upper bound over duration seconds, along curve.

Source

pub fn reverse(&mut self, duration: f32, curve: Curve)

Animates to the lower bound over duration seconds, along curve.

Source

pub fn animate_to(&mut self, target: f32, duration: f32, curve: Curve)

Animates the current value towards target over duration seconds. This cancels any repeat loop, making it a one-shot animation.

Source

pub fn repeat(&mut self, period: f32, reverse: bool, curve: Curve)

Repeats the animation in a loop, each cycle lasting period seconds and shaped by curve. With reverse it goes there and back (0→1→0…); otherwise each cycle restarts from the bottom (0→1, 0→1…). It only ends at stop, or set_value / animate_to. This is the idiom for continuous driven animations: a pulse, a busy indicator, a halo.

Source

pub fn fling(&mut self, velocity: f32)

Launches a physical fling: a critical spring started by velocity, settling on the position, bounded to [lower, upper].

Source

pub fn spring_to( &mut self, target: f32, spring: SpringDescription, velocity: f32, )

Animates the current value towards target with a spring described by spring, started at velocity (units/s). This is the path taken by interruptible, gesture-driven transitions — a drag release, a back gesture carried by the finger’s momentum: the spring starts from the current position and the current velocity.

Source

pub fn drive(&mut self, simulation: Box<dyn Simulation>, heading_up: bool)

Drives an arbitrary simulation — scroll momentum, a bespoke curve.

Source

pub fn tick(&mut self, dt: f32) -> bool

Advances the animation by dt seconds, updating value, velocity and status. Returns true while the animation continues, meaning another frame is due.

Trait Implementations§

Source§

impl Default for AnimationController

Source§

fn default() -> AnimationController

A standard controller over [0, 1], at rest at 0.

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> 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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
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, !>

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.