Skip to main content

AnimationExt

Trait AnimationExt 

Source
pub trait AnimationExt {
    // Provided methods
    fn with_animation(
        self,
        id: impl Into<ElementId>,
        animation: Animation,
        animator: impl Fn(Self, f32) -> Self + 'static,
    ) -> AnimationElement<Self>
       where Self: Sized { ... }
    fn with_animations(
        self,
        id: impl Into<ElementId>,
        animations: Vec<Animation>,
        animator: impl Fn(Self, usize, f32) -> Self + 'static,
    ) -> AnimationElement<Self>
       where Self: Sized { ... }
    fn with_spring<T>(
        self,
        id: impl Into<ElementId>,
        animation: SpringAnimation<T>,
        animator: impl FnOnce(Self, T::Output) -> Self + 'static,
    ) -> SpringAnimationElement<Self>
       where Self: Sized,
             T: SpringTarget,
             T::Output: 'static { ... }
}
Expand description

An extension trait for adding the animation wrapper to both Elements and Components

Animations rendered through this trait automatically respect App::reduce_motion: when it is set, the element is rendered in a static state (the end state for oneshot animations, the start state for repeating ones) and no animation frames are scheduled.

Provided Methods§

Source

fn with_animation( self, id: impl Into<ElementId>, animation: Animation, animator: impl Fn(Self, f32) -> Self + 'static, ) -> AnimationElement<Self>
where Self: Sized,

Render this component or element with an animation

Source

fn with_animations( self, id: impl Into<ElementId>, animations: Vec<Animation>, animator: impl Fn(Self, usize, f32) -> Self + 'static, ) -> AnimationElement<Self>
where Self: Sized,

Render this component or element with a chain of animations

Source

fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, T::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
where Self: Sized, T: SpringTarget, T::Output: 'static,

Renders this component or element at the value produced by a spring.

The element ID preserves position and velocity across target changes. A newly mounted spring starts at its target unless configured with SpringAnimation::from.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<E: IntoElement + 'static> AnimationExt for E