pub struct AnimationController { /* private fields */ }Expand description
Drives a value bounded to [lower, upper] through a pluggable simulation.
Implementations§
Source§impl AnimationController
impl AnimationController
Sourcepub fn new(lower: f32, upper: f32) -> Self
pub fn new(lower: f32, upper: f32) -> Self
A controller bounding its value to [lower, upper], starting at lower.
Sourcepub fn is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
true while a simulation is running, meaning a frame is needed.
Sourcepub fn set_value(&mut self, value: f32)
pub fn set_value(&mut self, value: f32)
Sets the value immediately, with no animation, and updates the status.
Sourcepub fn stop(&mut self)
pub fn stop(&mut self)
Stops any animation, a AnimationController::repeat loop included, and
freezes the current value.
Sourcepub fn forward(&mut self, duration: f32, curve: Curve)
pub fn forward(&mut self, duration: f32, curve: Curve)
Animates to the upper bound over duration seconds, along curve.
Sourcepub fn reverse(&mut self, duration: f32, curve: Curve)
pub fn reverse(&mut self, duration: f32, curve: Curve)
Animates to the lower bound over duration seconds, along curve.
Sourcepub fn animate_to(&mut self, target: f32, duration: f32, curve: Curve)
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.
Sourcepub fn repeat(&mut self, period: f32, reverse: bool, curve: Curve)
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.
Sourcepub fn fling(&mut self, velocity: f32)
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].
Sourcepub fn spring_to(
&mut self,
target: f32,
spring: SpringDescription,
velocity: f32,
)
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.
Sourcepub fn drive(&mut self, simulation: Box<dyn Simulation>, heading_up: bool)
pub fn drive(&mut self, simulation: Box<dyn Simulation>, heading_up: bool)
Drives an arbitrary simulation — scroll momentum, a bespoke curve.