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 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 restart_count(&self) -> usize
pub fn restart_count(&self) -> usize
Number of times the animation restarted.
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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> 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