pub struct AnimationConfig {
pub mode: AnimationMode,
pub loop_mode: Option<LoopMode>,
pub delay: Duration,
pub on_complete: Option<Arc<Mutex<dyn FnMut() + Send>>>,
pub epsilon: Option<f32>,
}Expand description
Configuration for an animation
Fields§
§mode: AnimationModeThe type of animation (Tween or Spring)
loop_mode: Option<LoopMode>How the animation should loop
delay: DurationDelay before animation starts
on_complete: Option<Arc<Mutex<dyn FnMut() + Send>>>Callback when animation completes
epsilon: Option<f32>Custom epsilon threshold for animation completion detection If None, uses the type’s default epsilon from Animatable::epsilon()
Implementations§
Source§impl AnimationConfig
impl AnimationConfig
Sourcepub fn new(mode: AnimationMode) -> Self
pub fn new(mode: AnimationMode) -> Self
Creates a new animation configuration with specified mode
Sourcepub fn with_delay(self, delay: Duration) -> Self
pub fn with_delay(self, delay: Duration) -> Self
Sets a delay before the animation starts
Sourcepub fn with_on_complete<F>(self, f: F) -> Self
pub fn with_on_complete<F>(self, f: F) -> Self
Sets a callback to be called when animation completes
Sourcepub fn with_epsilon(self, epsilon: f32) -> Self
pub fn with_epsilon(self, epsilon: f32) -> Self
Sets a custom epsilon threshold for animation completion detection
§Arguments
epsilon- The minimum meaningful difference between values for completion detection
§Examples
use dioxus_motion::prelude::*;
let config = AnimationConfig::new(AnimationMode::Spring(Spring::default()))
.with_epsilon(0.01); // Custom threshold for page transitionsSourcepub fn get_duration(&self) -> Duration
pub fn get_duration(&self) -> Duration
Gets the total duration of the animation
Sourcepub fn execute_completion(&mut self)
pub fn execute_completion(&mut self)
Execute the completion callback if it exists
Trait Implementations§
Source§impl Clone for AnimationConfig
impl Clone for AnimationConfig
Source§fn clone(&self) -> AnimationConfig
fn clone(&self) -> AnimationConfig
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 Default for AnimationConfig
impl Default for AnimationConfig
Source§fn default() -> AnimationConfig
fn default() -> AnimationConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for AnimationConfig
impl RefUnwindSafe for AnimationConfig
impl Send for AnimationConfig
impl Sync for AnimationConfig
impl Unpin for AnimationConfig
impl UnwindSafe for AnimationConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.