Skip to main content

Act

Struct Act 

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

An Act is a named segment of time with animated properties.

Implementations§

Source§

impl Act

Source

pub fn new(name: impl Into<String>) -> Self

Create a new act with the given name.

Source

pub fn hold(name: impl Into<String>, duration: f64) -> Self

Create a hold act (no animations, just wait).

Source

pub fn transition(name: impl Into<String>, duration: f64) -> Self

Create a transition act with a specific duration.

Source

pub fn duration(self, seconds: f64) -> Self

Set the duration of this act in seconds.

Source

pub fn animate<T: Animatable>( self, property: impl Into<String>, from: T, to: T, easing: Easing, ) -> Self

Add a simple from->to animation for a property.

Source

pub fn track<T: Animatable>( self, property: impl Into<String>, track: Track<T>, ) -> Self

Add a track with full keyframe control.

Source

pub fn spring<T: Animatable>( self, property: impl Into<String>, from: T, to: T, spring: Spring, ) -> Self

Add a spring-based animation for a property.

Spring animations provide natural, physics-based motion with overshoots and settling behavior.

§Example
Act::new("bounce_in")
    .duration(1.0)
    .spring("position", 0.0, 100.0, Spring::preset_bouncy())
Source

pub fn spring_track<T: Animatable>( self, property: impl Into<String>, track: SpringTrack<T>, ) -> Self

Add a spring track with full control.

Source

pub fn stagger<T: Animatable>( self, property: impl Into<String>, count: usize, from: T, to: T, easing: Easing, ) -> Self

Add a staggered animation for multiple items.

Stagger animations apply the same animation to multiple items with a delay between each one, creating a wave or cascade effect.

§Example
Act::new("panels_enter")
    .duration(2.0)
    .stagger("panel_opacity", 5, 0.0f64, 1.0, Easing::EaseOutCubic)
Source

pub fn stagger_config<T: Animatable>( self, property: impl Into<String>, config: StaggerConfig<T>, ) -> Self

Add a staggered animation with full configuration.

§Example
Act::new("panels_enter")
    .duration(2.0)
    .stagger_config("panel_opacity", StaggerConfig::new(5, 0.0f64, 1.0)
        .delay(0.15)
        .order(StaggerOrder::CenterOut)
        .easing(Easing::EaseOutElastic))
Source

pub fn stagger_track<T: Animatable>( self, property: impl Into<String>, track: StaggerTrack<T>, ) -> Self

Add a stagger track directly.

Source

pub fn name(&self) -> &str

Get the name of this act.

Source

pub fn get_duration(&self) -> f64

Get the duration of this act in seconds.

Source

pub fn has_stagger(&self, property: &str) -> bool

Check if this act has a stagger track for the given property.

Source

pub fn on_enter<F: Fn() + 'static>(self, callback: F) -> Self

Set a callback to fire when entering this act.

§Example
Act::new("intro")
    .duration(2.0)
    .on_enter(|| println!("Intro started!"))
Source

pub fn on_exit<F: Fn() + 'static>(self, callback: F) -> Self

Set a callback to fire when exiting this act.

§Example
Act::new("intro")
    .duration(2.0)
    .on_exit(|| println!("Intro complete!"))

Trait Implementations§

Source§

impl Clone for Act

Source§

fn clone(&self) -> Act

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

Auto Trait Implementations§

§

impl Freeze for Act

§

impl !RefUnwindSafe for Act

§

impl !Send for Act

§

impl !Sync for Act

§

impl Unpin for Act

§

impl !UnwindSafe for Act

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.