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.
impl TransitionState
Inherent implementation of TransitionState.
Sourcepub fn is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
Returns true if the element is currently
animating (i.e. Entering or Exiting).
§Returns
bool-truewhen an animation is currently running.
Sourcepub fn change_config(&self, config: TransitionConfig)
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- ATransitionConfigparameter.
Sourcepub fn enter(&self)
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.
Sourcepub fn exit(&self)
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.
Sourcepub fn toggle(&self)
pub fn toggle(&self)
Toggles between Entered and Exited. Equivalent
to enter() if currently Exiting / Exited,
and exit() if currently Entering / Entered.
Sourcepub fn tick(&self, elapsed_ms: u32)
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 lasttickcall. Must be non-negative. The state does not validate this; passing0is a no-op, passing a value larger than the remaining duration jumps directly to the terminal phase.
Sourcepub fn tick_until_done(&self, step_ms: u32)
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 is16(≈60 fps).
Sourcepub fn reset(&self)
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.
Sourcepub fn remaining_ms(&self) -> u32
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
impl TransitionState
pub fn get_phase(&self) -> &Signal<TransitionPhase>
pub fn get_mut_phase(&mut self) -> &mut Signal<TransitionPhase>
pub fn set_phase(&mut self, val: Signal<TransitionPhase>) -> &mut Self
pub fn get_progress(&self) -> &Signal<f64>
pub fn get_mut_progress(&mut self) -> &mut Signal<f64>
pub fn set_progress(&mut self, val: Signal<f64>) -> &mut Self
pub fn get_config(&self) -> &Signal<TransitionConfig>
pub fn get_mut_config(&mut self) -> &mut Signal<TransitionConfig>
pub fn set_config(&mut self, val: Signal<TransitionConfig>) -> &mut Self
Source§impl TransitionState
impl TransitionState
pub fn new( phase: Signal<TransitionPhase>, progress: Signal<f64>, config: Signal<TransitionConfig>, ) -> Self
Trait Implementations§
Source§impl Clone for TransitionState
impl Clone for TransitionState
Source§fn clone(&self) -> TransitionState
fn clone(&self) -> TransitionState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more