Skip to main content

TransitionState

Struct TransitionState 

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

The aggregate transition state.

Constructed once per animated element via App::use_transition(...). Cheap to Clone (each internal signal is Copy-by-pointer). Drives the state machine forward via tick(elapsed_ms) and exposes the current phase / progress as reactive signals so the consuming component’s render closure re-runs whenever either changes.

Implementations§

Source§

impl TransitionState

Inherent implementation of TransitionState.

Source

pub fn is_animating(&self) -> bool

Returns true if the element is currently animating (i.e. Entering or Exiting).

§Returns
  • bool - true when an animation is currently running.
Source

pub fn change_config(&self, config: TransitionConfig)

Replaces the duration config.

Named change_config (not set_config) to avoid colliding with the set_config setter generated by #[derive(Data)] on the struct field.

§Arguments
  • TransitionConfig - A TransitionConfig parameter.
Source

pub fn enter(&self)

Starts the enter animation. Sets the phase to Entering and resets progress to 0.0. No-op if the transition is already in Entering / Entered.

Source

pub fn exit(&self)

Starts the exit animation. Sets the phase to Exiting and starts progress from 1.0. No-op if the transition is already in Exiting / Exited.

Source

pub fn toggle(&self)

Toggles between Entered and Exited. Equivalent to enter() if currently Exiting / Exited, and exit() if currently Entering / Entered.

Source

pub fn tick(&self, elapsed_ms: u32)

Advances the transition by elapsed_ms milliseconds. Updates progress and, if the transition has reached its end, advances the phase to the corresponding terminal phase (Entered or Exited).

This is the primitive the consumer drives from a setInterval or requestAnimationFrame loop. The state itself does NOT spawn a timer — that would require wasm_bindgen_futures::spawn_local and would prevent the primitive from being usable on native targets. Instead, the consumer is expected to wire up the timer (see the docs on tick_until_done for a helper that drives tick in a loop).

§Arguments
  • u32 - The number of milliseconds that have elapsed since the last tick call. Must be non-negative. The state does not validate this; passing 0 is a no-op, passing a value larger than the remaining duration jumps directly to the terminal phase.
Source

pub fn tick_until_done(&self, step_ms: u32)

Drives tick until the transition reaches a terminal phase (Entered or Exited), using step_ms as the per-tick delta.

Useful for tests and for native builds that want to fast-forward a transition synchronously. On wasm the consumer should NOT use this — instead drive tick from a real timer loop and render each frame.

§Arguments
  • u32 - The per-tick delta, in milliseconds. Typical value is 16 (≈60 fps).
Source

pub fn reset(&self)

Resets the transition back to the Exited state (progress = 0.0). Cancels any in-flight animation immediately. Useful for “the user closed the dialog before the exit animation finished, force-reset” flows.

Source

pub fn remaining_ms(&self) -> u32

Returns the time remaining (in ms) until the current transition completes. Returns 0 for terminal phases.

§Returns
  • u32 - Milliseconds remaining before the transition ends.
Source§

impl TransitionState

Source

pub fn get_phase(&self) -> &Signal<TransitionPhase>

Source

pub fn get_mut_phase(&mut self) -> &mut Signal<TransitionPhase>

Source

pub fn set_phase(&mut self, val: Signal<TransitionPhase>) -> &mut Self

Source

pub fn get_progress(&self) -> &Signal<f64>

Source

pub fn get_mut_progress(&mut self) -> &mut Signal<f64>

Source

pub fn set_progress(&mut self, val: Signal<f64>) -> &mut Self

Source

pub fn get_config(&self) -> &Signal<TransitionConfig>

Source

pub fn get_mut_config(&mut self) -> &mut Signal<TransitionConfig>

Source

pub fn set_config(&mut self, val: Signal<TransitionConfig>) -> &mut Self

Source§

impl TransitionState

Source

pub fn new( phase: Signal<TransitionPhase>, progress: Signal<f64>, config: Signal<TransitionConfig>, ) -> Self

Trait Implementations§

Source§

impl Clone for TransitionState

Source§

fn clone(&self) -> TransitionState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. 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 = !

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more