Animation

Struct Animation 

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

The main animation struct

Use Animation::new or the Decorators::animation method to build an animation.

Implementations§

Source§

impl Animation

§Methods for creating an animation, including methods that quickly initialize the animation for specific uses

Source

pub fn new() -> Self

Create a new animation

Source

pub fn view_transition(self) -> Self

Quickly set a few properties on an animation to set up an animation to be used as a view transition (on creation and removal). (Sets keyframes 0 and 100 to use the computed style until overridden)

Source

pub fn view_transition_with_ease( self, ease: impl Easing + 'static + Clone, ) -> Self

Quickly set an animation to be a view transition and override the default easing function on keyframes 0 and 100.

Source

pub fn scale_effect(self) -> Self

Quickly set an animation to be a view transition and set the animation to animate from scale 0% to the “normal” computed style of a view (the view with no animations applied).

Source

pub fn scale_size_effect(self) -> Self

Quickly set an animation to be a view transition and set the animation to animate from size(0, 0) to the “normal” computed style of a view (the view with no animations applied).

Source§

impl Animation

§Methods for setting properties on an Animation

Source

pub fn keyframe( self, frame_id: u16, key_frame: impl Fn(KeyFrame) -> KeyFrame, ) -> Self

Build a KeyFrame

If there is a matching keyframe id, the style in this keyframe will only override the style values in the new style. If you want the style to completely override style see Animation::keyframe_override.

Source

pub fn keyframe_override( self, frame_id: u16, key_frame: impl Fn(KeyFrame) -> KeyFrame, ) -> Self

Build and overwrite a KeyFrame

If there is a matching keyframe id, the style in this keyframe will completely override the style in the frame that already exists. If you want the style to only override the new values see Animation::keyframe.

Source

pub const fn duration(self, duration: Duration) -> Self

Sets the perceived duration of the animation.

The total duration of an animation will run until all animating props return finished. This is useful for spring animations which don’t conform well to strict ending times.

Source

pub fn with_duration( self, duration: impl FnOnce(Self, Duration) -> Self, ) -> Self

Set properties on the animation while having access to the current duration.

Source

pub fn apply_if(self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self

Conditionally apply properties to this animation if the condition is true.

Source

pub fn on_create(self, on_create: impl FnOnce(Trigger) + 'static) -> Self

Provides access to the on create trigger by calling the closure in once and then returning self.

Source

pub fn on_visual_complete( self, on_visual_complete: impl FnOnce(Trigger) + 'static, ) -> Self

Provides access to the on visual complete trigger by calling the closure once and then returning self.

Source

pub fn on_complete(self, on_complete: impl FnOnce(Trigger) + 'static) -> Self

Provides access to the on complete trigger by calling the closure once and then returning self.

Source

pub const fn run_on_create(self, run_on_create: bool) -> Self

Set whether this animation should run when being created.

I.e when being created by a dyn container or when being shown after being hidden.

Source

pub const fn only_on_create(self) -> Self

Set whether this animation should run when being created and not when being removed.

Source

pub const fn run_on_remove(self, run_on_remove: bool) -> Self

Set whether this animation should run when being removed. I.e when being removed by a dyn container or when being hidden.

Source

pub const fn only_on_remove(self) -> Self

Set whether this animation should run when being removed and not when being created.

Source

pub const fn apply_when_finished(self, apply: bool) -> Self

Set whether the properties from the final keyframe of this animation should be applied even when the animation is finished.

Source

pub const fn auto_reverse(self, auto_rev: bool) -> Self

Sets if this animation should auto reverse. If true, the animation will reach the final key frame twice as fast and then animate backwards

Source

pub const fn reverse_on_exit(self, allow: bool) -> Self

Sets if this animation should be allowed to be reversed when the view is being removed or hidden.

Source

pub const fn delay(self, delay: Duration) -> Self

Sets a delay for how long the animation should wait before starting.

Source

pub const fn delay_on_reverse(self, on_reverse: bool) -> Self

Sets whether the animation should delay when reversing.

Source

pub const fn repeat(self, repeat: bool) -> Self

Sets if the animation should the repeat forever.

Source

pub const fn repeat_times(self, times: usize) -> Self

Sets the number of times the animation should repeat.

Source

pub const fn max_key_frame(self, max: u16) -> Self

This is used to determine which keyframe is at 100% completion.

The default is 100.

If you need more than 100 keyframes, increase this number, but be aware, the keyframe numbers will then be as a percentage of the maximum.

This does not move existing keyframes.

Source

pub fn initial_state(self, command: AnimStateCommand) -> Self

Mutably sets the initial state of the animation

Source

pub fn state( self, command: impl Fn() -> AnimStateCommand + 'static, apply_initial: bool, ) -> Self

If apply_initial is false the initial command will not be applied to the animation. This is useful if you want the effect to be subscribed to changes but not run the first time.

Source

pub fn pause(self, trigger: impl Fn() + 'static) -> Self

The animation will receive a pause command any time the trigger function tracks any reactive updates.

Source

pub fn resume(self, trigger: impl Fn() + 'static) -> Self

The animation will receive a resume command any time the trigger function tracks any reactive updates.

Source

pub fn start(self, trigger: impl Fn() + 'static) -> Self

The animation will receive a start command any time the trigger function tracks any reactive updates.

Source

pub fn reverse(self, trigger: impl Fn() + 'static) -> Self

The animation will receive a reverse command any time the trigger function tracks any reactive updates.

This will start the animation in reverse

Source

pub fn stop(self, trigger: impl Fn() + 'static) -> Self

The animation will receive a stop command any time the trigger function tracks any reactive updates.

Source

pub fn debug_name(self, description: impl Into<String>) -> Self

Add a debug description to the animation

Source

pub const fn state_kind(&self) -> AnimStateKind

Matches the current state of the animation and returns the kind of state it is in.

Source

pub fn elapsed(&self) -> Option<Duration>

Returns the current amount of time that has elapsed since the animation started.

Source

pub fn advance(&mut self)

Advance the animation.

Source

pub fn animate_into(&mut self, computed_style: &mut Style)

While advancing, this function can mutably apply it’s animated props to a style.

Source

pub fn is_idle(&self) -> bool

returns true if the animation is in the idle state

Source

pub fn is_in_progress(&self) -> bool

returns true if the animation is in the pass in progress state

Source

pub fn is_completed(&self) -> bool

returns true if the animation is in the completed state

Source

pub fn is_stopped(&self) -> bool

returns true if the animation is in the stopped state

Source

pub const fn can_advance(&self) -> bool

returns true if the animation can advance, which either means the animation will transition states, or properties can be animated and updated

Source

pub const fn is_auto_reverse(&self) -> bool

returns true if the animation should auto reverse

Source

pub fn should_apply_folded(&self) -> bool

Returns true if the internal folded style of the animation should be applied.

This is used when the animation cannot advance but the folded style should still be applied. For example, when the animation is paused or when apply_when_finished is set.

Source

pub fn apply_folded(&self, computed_style: &mut Style)

Apply the folded (last computed) style values to the given computed style.

This is used when the animation is paused or completed but should still apply its last interpolated values.

Trait Implementations§

Source§

impl Clone for Animation

Source§

fn clone(&self) -> Animation

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Animation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Animation

Source§

fn default() -> Self

Returns the “default value” for a type. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,

Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,