pub struct Animation(/* private fields */);Expand description
Represents an animation in its closure.
See the VARS.animate method for more details.
Implementations§
Source§impl Animation
impl Animation
Sourcepub fn start_time(&self) -> DInstant
pub fn start_time(&self) -> DInstant
The instant this animation (re)started.
Sourcepub fn now(&self) -> DInstant
pub fn now(&self) -> DInstant
The instant the current animation update started.
Use this value instead of INSTANT.now, animations update sequentially, but should behave as if
they are updating exactly in parallel, using this timestamp ensures that.
Sourcepub fn time_scale(&self) -> Factor
pub fn time_scale(&self) -> Factor
Global time scale for animations.
Sourcepub fn sleep(&self, duration: Duration)
pub fn sleep(&self, duration: Duration)
Set the duration to the next animation update. The animation will sleep until duration elapses.
The animation awakes in the next VARS.frame_duration after the duration elapses. The minimum
possible duration is the frame duration, shorter durations behave the same as if not set.
Sourcepub fn sleep_restart(&self, duration: Duration)
pub fn sleep_restart(&self, duration: Duration)
Sourcepub fn animations_enabled(&self) -> bool
pub fn animations_enabled(&self) -> bool
Returns a value that indicates if animations are enabled in the operating system.
If false all animations must be skipped to the end, users with photo-sensitive epilepsy disable animations system wide.
Sourcepub fn force_enable(&self)
pub fn force_enable(&self)
Set animations_enabled to true.
This should only be used for animations that are component of an app feature, cosmetic animations must not force enable.
Sourcepub fn elapsed_dur(&self) -> Duration
pub fn elapsed_dur(&self) -> Duration
Compute the time elapsed from start_time to now.
Sourcepub fn elapsed(&self, duration: Duration) -> EasingTime
pub fn elapsed(&self, duration: Duration) -> EasingTime
Compute the elapsed EasingTime, in the span of the total duration, if animations_enabled.
If animations are disabled, returns EasingTime::end, the returned time is scaled.
Sourcepub fn elapsed_stop(&self, duration: Duration) -> EasingTime
pub fn elapsed_stop(&self, duration: Duration) -> EasingTime
Compute the elapsed EasingTime, if the time is_end requests animation stop.
Sourcepub fn elapsed_restart(&self, duration: Duration) -> EasingTime
pub fn elapsed_restart(&self, duration: Duration) -> EasingTime
Compute the elapsed EasingTime, if the time is_end restarts the animation.
Sourcepub fn elapsed_restart_stop(
&self,
duration: Duration,
max_restarts: usize,
) -> EasingTime
pub fn elapsed_restart_stop( &self, duration: Duration, max_restarts: usize, ) -> EasingTime
Compute the elapsed EasingTime, if the time is_end restarts the animation, repeats until has
restarted max_restarts inclusive, then stops the animation.
Sourcepub fn stop_requested(&self) -> bool
pub fn stop_requested(&self) -> bool
If the animation will be dropped after applying the update.
Sourcepub fn set_start_time(&self, instant: DInstant)
pub fn set_start_time(&self, instant: DInstant)
Change the start time to an arbitrary value.
Note that this does not affect the restart count.
Sourcepub fn set_elapsed(&self, elapsed: EasingTime, duration: Duration)
pub fn set_elapsed(&self, elapsed: EasingTime, duration: Duration)
Change the start to an instant that computes the elapsed for the duration at the moment
this method is called.
Note that this does not affect the restart count.
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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