pub struct Stagger { /* private fields */ }Expand description
Delays each item in a list so a group animates as a wave.
The total is capped so a long list stays responsive: past max_items the
per-item delay shrinks instead of the sequence growing without bound.
Implementations§
Source§impl Stagger
impl Stagger
pub fn new(step: Duration, max_items: usize) -> Self
pub fn from_millis(step_ms: u64) -> Self
Sourcepub fn rows() -> Self
pub fn rows() -> Self
The wave a list of menu-shaped rows arrives on.
Sixteen milliseconds a row across at most eight rows, so the last row in a fifty-row menu starts 112ms after the first rather than a second later: past eight rows the step shrinks to keep the window fixed.
pub fn max_items(self, max_items: usize) -> Self
Sourcepub fn reversed(self) -> Self
pub fn reversed(self) -> Self
Runs the wave from the last item to the first.
This is the order a list leaves on. A list that arrived from the top down should depart from the bottom up, so the row the user is looking at — the one they just acted on, at the top — is the last to go rather than the first, and the group empties away from them instead of out from under them.
pub fn is_reversed(&self) -> bool
pub fn delay(&self, index: usize, count: usize) -> Duration
Sourcepub fn total(&self, count: usize, spec: MotionSpec) -> Duration
pub fn total(&self, count: usize, spec: MotionSpec) -> Duration
The window the whole group occupies, including the last item’s span.
Reversing changes which item waits longest, not how long the group takes, so the window is measured from the furthest place rather than from the last index.
Sourcepub fn spec(&self, index: usize, count: usize, spec: MotionSpec) -> MotionSpec
pub fn spec(&self, index: usize, count: usize, spec: MotionSpec) -> MotionSpec
Applies the delay for one item to a spec.
Trait Implementations§
impl Copy for Stagger
impl StructuralPartialEq for Stagger
Auto Trait Implementations§
impl Freeze for Stagger
impl RefUnwindSafe for Stagger
impl Send for Stagger
impl Sync for Stagger
impl Unpin for Stagger
impl UnsafeUnpin for Stagger
impl UnwindSafe for Stagger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more