Skip to main content

Stagger

Struct Stagger 

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

Configuration for staggering multiple animations.

§Examples

use eazy_tweener::{Stagger, StaggerFrom};

// Each animation starts 0.1s after the previous
let stagger = Stagger::each(0.1);

// Stagger from center outward
let stagger = Stagger::each(0.1).from(StaggerFrom::Center);

// Apply easing to the stagger distribution
let stagger = Stagger::each(0.1).ease(eazy_core::Easing::OutQuadratic);

Implementations§

Source§

impl Stagger

Source

pub fn each(delay: f32) -> Stagger

Create a stagger with the given delay between each animation.

Source

pub fn total(duration: f32) -> Stagger

Create a stagger that distributes animations across a total duration.

The delay between each animation is calculated as total / (count - 1).

Source

pub fn from(self, from: StaggerFrom) -> Stagger

Set the stagger direction.

Source

pub fn ease(self, easing: Easing) -> Stagger

Apply an easing function to the stagger distribution.

This affects how the delays are distributed, not the animations themselves.

Source

pub fn delay_for(&self, index: usize, total: usize) -> f32

Get the delay for a specific index in a collection.

§Parameters
  • index: The position of this animation (0-based)
  • total: Total number of animations
§Returns

The delay in seconds before this animation should start.

Source

pub fn total_stagger_duration(&self, count: usize) -> f32

Get the total stagger duration for a collection.

This is the delay of the last animation to start.

Source

pub fn each_delay(&self) -> f32

Get the each delay value.

Source

pub fn direction(&self) -> StaggerFrom

Get the stagger direction.

Trait Implementations§

Source§

impl Clone for Stagger

Source§

fn clone(&self) -> Stagger

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Stagger

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Stagger

Source§

fn default() -> Stagger

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.