pub struct ToastAnimationState {
pub phase: ToastAnimationPhase,
pub phase_started: Instant,
pub reduced_motion: bool,
}Expand description
Tracks the animation state for a toast.
Fields§
§phase: ToastAnimationPhaseCurrent animation phase.
phase_started: InstantWhen the current phase started.
reduced_motion: boolWhether reduced motion is active.
Implementations§
Source§impl ToastAnimationState
impl ToastAnimationState
Sourcepub fn with_reduced_motion() -> Self
pub fn with_reduced_motion() -> Self
Create a state with reduced motion enabled (skips to Visible).
Sourcepub fn progress(&self, phase_duration: Duration) -> f64
pub fn progress(&self, phase_duration: Duration) -> f64
Get the progress within the current phase (0.0 to 1.0).
Sourcepub fn transition_to(&mut self, phase: ToastAnimationPhase)
pub fn transition_to(&mut self, phase: ToastAnimationPhase)
Transition to the next phase.
Sourcepub fn start_exit(&mut self)
pub fn start_exit(&mut self)
Start the exit animation.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if the animation has completed (Hidden phase).
Sourcepub fn tick(&mut self, config: &ToastAnimationConfig) -> bool
pub fn tick(&mut self, config: &ToastAnimationConfig) -> bool
Update the animation state based on elapsed time.
Returns true if the phase changed.
Sourcepub fn current_offset(
&self,
config: &ToastAnimationConfig,
toast_width: u16,
toast_height: u16,
) -> (i16, i16)
pub fn current_offset( &self, config: &ToastAnimationConfig, toast_width: u16, toast_height: u16, ) -> (i16, i16)
Calculate the current animation offset.
Returns (dx, dy) offset to apply to the toast position.
Sourcepub fn current_opacity(&self, config: &ToastAnimationConfig) -> f64
pub fn current_opacity(&self, config: &ToastAnimationConfig) -> f64
Calculate the current opacity (0.0 to 1.0).
Used for fade animations.
Trait Implementations§
Source§impl Clone for ToastAnimationState
impl Clone for ToastAnimationState
Source§fn clone(&self) -> ToastAnimationState
fn clone(&self) -> ToastAnimationState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ToastAnimationState
impl Debug for ToastAnimationState
Auto Trait Implementations§
impl Freeze for ToastAnimationState
impl RefUnwindSafe for ToastAnimationState
impl Send for ToastAnimationState
impl Sync for ToastAnimationState
impl Unpin for ToastAnimationState
impl UnsafeUnpin for ToastAnimationState
impl UnwindSafe for ToastAnimationState
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
Mutably borrows from an owned value. Read more