Skip to main content

Motion

Struct Motion 

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

Animated values for a view’s opacity and the parts of its transform (TS: createMotion), and motions to play on them: presets (crate::animation::MotionPreset: entrances, exits, attention seekers, loops) or keyframes of the app’s own (MotionSpec). Bind it with [super::Styled::bind_motion]. A Copy handle, kept by the owner current when it is made, as an AnimatedValue is.

ⓘ
let card = motion().entering(MotionPreset::FadeInUp);
view().bind_motion(&card).on_press(move || {
    card.play(MotionPreset::Pulse);
})

Implementations§

Source§

impl Motion

Source

pub fn value(&self, channel: MotionChannel) -> AnimatedValue

The value of channel (opacity 0..1, translations in points, rotations in degrees, scales).

Source

pub fn entering(self, motion: impl Into<MotionSpec>) -> Self

Starting where motion starts and playing it at once: a view that comes in shows its first frame where the motion begins.

Source

pub fn play(&self, motion: impl Into<MotionSpec>) -> AnimationEnd

Plays motion on its channels (a new one interrupts the one playing). When the user asks for less motion (super::reduce_motion), it lands where it ends without moving.

Source

pub fn play_ignoring_reduce_motion( &self, motion: impl Into<MotionSpec>, ) -> AnimationEnd

Plays motion even when the user asks for less motion.

Source

pub fn animation(&self, motion: impl Into<MotionSpec>) -> Animation

motion as an Animation to compose, not started (TS: motion.animation(..)): Animation::stagger_from(60.0, StaggerFrom::Center, cards.iter().map(|m| m.animation(..))). Like Self::play, it lands at its end when the user asks for less motion (as things are when it is made).

Source

pub fn stop(&self)

Stops it where it is.

Source

pub fn reset(&self)

Stops it and puts every channel back at rest.

Trait Implementations§

Source§

impl Clone for Motion

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Motion

Source§

impl Debug for Motion

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Motion

§

impl Freeze for Motion
where PhantomData<fn() -> Node>: Freeze,

§

impl Move for Motion

§

impl RefUnwindSafe for Motion

§

impl Send for Motion

§

impl Sync for Motion

§

impl Unpin for Motion

§

impl UnsafeUnpin for Motion
where PhantomData<fn() -> Node>: UnsafeUnpin,

§

impl UnwindSafe for Motion

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.