Inertial

Struct Inertial 

Source
pub struct Inertial<Item: Mix + Clone + PartialEq, X: Time> { /* private fields */ }
Expand description

A value that smoothly goes to the target during a specific time. The target can be changed at any time. No jumps will occur. It’s expected that time is always increasing. Every method receives current_time as a parameter to allow testing, and has a consistent behavior during a single animation frame.

Implementations§

Source§

impl<Item: Mix + Clone + PartialEq, X: Time> Inertial<Item, X>

Source

pub fn new(value: Item) -> Self

Create a new inertial value at a specific time.

Source

pub fn target(&self) -> Item

Get the target value.

Source

pub fn end_time(&self) -> Option<X>

Get transition end time.

Source

pub fn go_to(self, target: Item, current_time: X, duration: X::Duration) -> Self

Create child inertial value with a new target at a specific time. Easing is set to default (QuadraticInOut).

  • target - The new target value.
  • current_time - The time to start the transition, usually Instant::now().
  • duration - The duration of the transition.
Source

pub fn ease_to( self, target: Item, current_time: X, duration: X::Duration, easing: Easing, ) -> Self

Create child inertial value with a new target, easing and start time.

  • target - The new target value.
  • start_time - The time to start the transition, usually Instant::now().
  • duration - The duration of the transition.

Trait Implementations§

Source§

impl<Item: Mix + Clone + PartialEq, X: Time> Animated<Item, X> for Inertial<Item, X>

Source§

fn is_finished(&self, current_time: X) -> bool

Check if the inertial value reached the target.

Source§

fn get(&self, current_time: X) -> Item

Get the value of the animation at a specific time. Read more
Source§

fn map<R, F: Fn(T) -> R>(self, map: F) -> AnimatedMap<T, X, Self, R, F>
where Self: Sized,

Map the animated value to another type.
Source§

fn join<T2, A2: Animated<T2, X>>( self, other: A2, ) -> AnimatedJoin<T, T2, X, Self, A2>
where Self: Sized,

Join two animated values into a single animated tuple. The resulting animation will be finished when both animations are finished.
Source§

fn flatten<R>(self) -> AnimatedFlatten<R, X, T, Self>
where Self: Sized, T: Animated<R, X>,

Flatten an animated value of an animated value into a single animated value. The resulting animation will be finished when both animations are finished.
Source§

impl<Item: Clone + Mix + Clone + PartialEq, X: Clone + Time> Clone for Inertial<Item, X>
where X::Duration: Clone,

Source§

fn clone(&self) -> Inertial<Item, X>

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<Item: Mix + Clone + PartialEq + Debug, X: Time + Debug> Debug for Inertial<Item, X>
where X::Duration: Debug,

Source§

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

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

impl<Item: Mix + Clone + PartialEq + Default, X: Time> Default for Inertial<Item, X>
where X::Duration: Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<Item: Mix + Clone + PartialEq, X: Time> From<Item> for Inertial<Item, X>

Source§

fn from(value: Item) -> Self

Converts to this type from the input type.
Source§

impl<Item: PartialEq + Mix + Clone + PartialEq, X: PartialEq + Time> PartialEq for Inertial<Item, X>
where X::Duration: PartialEq,

Source§

fn eq(&self, other: &Inertial<Item, X>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Item: Mix + Clone + PartialEq, X: Time> StructuralPartialEq for Inertial<Item, X>

Auto Trait Implementations§

§

impl<Item, X> Freeze for Inertial<Item, X>
where Item: Freeze, <X as Time>::Duration: Freeze, X: Freeze,

§

impl<Item, X> RefUnwindSafe for Inertial<Item, X>

§

impl<Item, X> Send for Inertial<Item, X>
where Item: Send, <X as Time>::Duration: Send, X: Send,

§

impl<Item, X> Sync for Inertial<Item, X>
where Item: Sync, <X as Time>::Duration: Sync, X: Sync,

§

impl<Item, X> Unpin for Inertial<Item, X>
where Item: Unpin, <X as Time>::Duration: Unpin, X: Unpin,

§

impl<Item, X> UnwindSafe for Inertial<Item, X>
where Item: UnwindSafe, <X as Time>::Duration: UnwindSafe, X: UnwindSafe,

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, 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> 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.