pub struct Stagger { /* private fields */ }Expand description
Parallel staggered animation where each item starts after a fixed delay.
Stagger applies one tween configuration to many items. The start tick for
each item is start_tick + delay_ticks * item_index.
By default the animation plays once (LoopMode::Once). Use
Stagger::loop_mode to repeat or ping-pong. The total cycle length
includes the delay of every item, so all items finish before the next
cycle begins.
§Example
use slt::anim::{ease_out_quad, Stagger, LoopMode};
let mut stagger = Stagger::new(0.0, 100.0, 30)
.easing(ease_out_quad)
.delay(5)
.loop_mode(LoopMode::Repeat);
stagger.reset(100);
let _ = stagger.value(120, 3);Implementations§
Source§impl Stagger
impl Stagger
Sourcepub fn new(from: f64, to: f64, duration_ticks: u64) -> Self
pub fn new(from: f64, to: f64, duration_ticks: u64) -> Self
Create a new stagger animation template.
Uses linear easing, zero delay, and LoopMode::Once by default.
Sourcepub fn loop_mode(self, mode: LoopMode) -> Self
pub fn loop_mode(self, mode: LoopMode) -> Self
Set loop behavior. LoopMode::Repeat restarts after all items
finish; LoopMode::PingPong reverses direction each cycle.
Sourcepub fn items(self, count: usize) -> Self
pub fn items(self, count: usize) -> Self
Set the number of items for cycle length calculation.
When using LoopMode::Repeat or LoopMode::PingPong, the total
cycle length is duration_ticks + delay_ticks * (item_count - 1).
If not set, it is inferred from the highest item_index seen.
Sourcepub fn value(&mut self, tick: u64, item_index: usize) -> f64
pub fn value(&mut self, tick: u64, item_index: usize) -> f64
Return the value for item_index at tick.