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
impl Animation
§Methods for creating an animation, including methods that quickly initialize the animation for specific uses
Sourcepub fn view_transition(self) -> Self
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)
Sourcepub fn view_transition_with_ease(
self,
ease: impl Easing + 'static + Clone,
) -> Self
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.
Sourcepub fn scale_effect(self) -> Self
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).
Sourcepub fn scale_size_effect(self) -> Self
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
impl Animation
§Methods for setting properties on an Animation
Sourcepub fn keyframe(
self,
frame_id: u16,
key_frame: impl Fn(KeyFrame) -> KeyFrame,
) -> Self
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.
Sourcepub fn keyframe_override(
self,
frame_id: u16,
key_frame: impl Fn(KeyFrame) -> KeyFrame,
) -> Self
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.
Sourcepub const fn duration(self, duration: Duration) -> Self
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.
Sourcepub fn with_duration(
self,
duration: impl FnOnce(Self, Duration) -> Self,
) -> Self
pub fn with_duration( self, duration: impl FnOnce(Self, Duration) -> Self, ) -> Self
Set properties on the animation while having access to the current duration.
Sourcepub fn apply_if(self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self
pub fn apply_if(self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self
Conditionally apply properties to this animation if the condition is true.
Sourcepub fn on_create(self, on_create: impl FnOnce(Trigger) + 'static) -> Self
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.
Sourcepub fn on_visual_complete(
self,
on_visual_complete: impl FnOnce(Trigger) + 'static,
) -> Self
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.
Sourcepub fn on_complete(self, on_complete: impl FnOnce(Trigger) + 'static) -> Self
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.
Sourcepub const fn run_on_create(self, run_on_create: bool) -> Self
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.
Sourcepub const fn only_on_create(self) -> Self
pub const fn only_on_create(self) -> Self
Set whether this animation should run when being created and not when being removed.
Sourcepub const fn run_on_remove(self, run_on_remove: bool) -> Self
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.
Sourcepub const fn only_on_remove(self) -> Self
pub const fn only_on_remove(self) -> Self
Set whether this animation should run when being removed and not when being created.
Sourcepub const fn apply_when_finished(self, apply: bool) -> Self
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.
Sourcepub const fn auto_reverse(self, auto_rev: bool) -> Self
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
Sourcepub const fn reverse_on_exit(self, allow: bool) -> Self
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.
Sourcepub const fn delay(self, delay: Duration) -> Self
pub const fn delay(self, delay: Duration) -> Self
Sets a delay for how long the animation should wait before starting.
Sourcepub const fn delay_on_reverse(self, on_reverse: bool) -> Self
pub const fn delay_on_reverse(self, on_reverse: bool) -> Self
Sets whether the animation should delay when reversing.
Sourcepub const fn repeat(self, repeat: bool) -> Self
pub const fn repeat(self, repeat: bool) -> Self
Sets if the animation should the repeat forever.
Sourcepub const fn repeat_times(self, times: usize) -> Self
pub const fn repeat_times(self, times: usize) -> Self
Sets the number of times the animation should repeat.
Sourcepub const fn max_key_frame(self, max: u16) -> Self
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.
Sourcepub fn initial_state(self, command: AnimStateCommand) -> Self
pub fn initial_state(self, command: AnimStateCommand) -> Self
Mutably sets the initial state of the animation
Sourcepub fn state(
self,
command: impl Fn() -> AnimStateCommand + 'static,
apply_initial: bool,
) -> Self
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.
Sourcepub fn pause(self, trigger: impl Fn() + 'static) -> Self
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.
Sourcepub fn resume(self, trigger: impl Fn() + 'static) -> Self
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.
Sourcepub fn start(self, trigger: impl Fn() + 'static) -> Self
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.
Sourcepub fn reverse(self, trigger: impl Fn() + 'static) -> Self
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
Sourcepub fn stop(self, trigger: impl Fn() + 'static) -> Self
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.
Sourcepub fn debug_name(self, description: impl Into<String>) -> Self
pub fn debug_name(self, description: impl Into<String>) -> Self
Add a debug description to the animation
Sourcepub const fn state_kind(&self) -> AnimStateKind
pub const fn state_kind(&self) -> AnimStateKind
Matches the current state of the animation and returns the kind of state it is in.
Sourcepub fn elapsed(&self) -> Option<Duration>
pub fn elapsed(&self) -> Option<Duration>
Returns the current amount of time that has elapsed since the animation started.
Sourcepub fn animate_into(&mut self, computed_style: &mut Style)
pub fn animate_into(&mut self, computed_style: &mut Style)
While advancing, this function can mutably apply it’s animated props to a style.
Sourcepub fn is_in_progress(&self) -> bool
pub fn is_in_progress(&self) -> bool
returns true if the animation is in the pass in progress state
Sourcepub fn is_completed(&self) -> bool
pub fn is_completed(&self) -> bool
returns true if the animation is in the completed state
Sourcepub fn is_stopped(&self) -> bool
pub fn is_stopped(&self) -> bool
returns true if the animation is in the stopped state
Sourcepub const fn can_advance(&self) -> bool
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
Sourcepub const fn is_auto_reverse(&self) -> bool
pub const fn is_auto_reverse(&self) -> bool
returns true if the animation should auto reverse
Sourcepub fn should_apply_folded(&self) -> bool
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.
Sourcepub fn apply_folded(&self, computed_style: &mut Style)
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§
Auto Trait Implementations§
impl Freeze for Animation
impl !RefUnwindSafe for Animation
impl !Send for Animation
impl !Sync for Animation
impl Unpin for Animation
impl !UnwindSafe for Animation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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