Skip to main content

TransitionScope

Struct TransitionScope 

Source
pub struct TransitionScope<T> { /* private fields */ }
Expand description

A scope for multi-target animations driven by a changing state.

When the target state changes (detected via PartialEq), all child animations registered via animate_float, animate_color, etc. automatically animate from their current value toward the new mapped target value.

§Example

let t = update_transition("panel", is_expanded, AnimationSpec::spring_gentle());
let h  = t.animate_float("height", |e| if *e { 200.0 } else { 48.0 });
let bg = t.animate_color("bg", |e| if *e { theme().primary } else { theme().surface });

Implementations§

Source§

impl<T> TransitionScope<T>

Source

pub fn animate_float<F>(&self, child_key: impl Into<String>, map: F) -> f32
where F: Fn(&T) -> f32,

Source

pub fn animate_color<F>(&self, child_key: impl Into<String>, map: F) -> Color
where F: Fn(&T) -> Color,

Source

pub fn animate_vec2<F>(&self, child_key: impl Into<String>, map: F) -> Vec2
where F: Fn(&T) -> Vec2,

Source

pub fn animate_size<F>(&self, child_key: impl Into<String>, map: F) -> Size
where F: Fn(&T) -> Size,

Source

pub fn animate_rect<F>(&self, child_key: impl Into<String>, map: F) -> Rect
where F: Fn(&T) -> Rect,

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for TransitionScope<T>

§

impl<T> !Send for TransitionScope<T>

§

impl<T> !Sync for TransitionScope<T>

§

impl<T> !UnwindSafe for TransitionScope<T>

§

impl<T> Freeze for TransitionScope<T>

§

impl<T> Unpin for TransitionScope<T>

§

impl<T> UnsafeUnpin for TransitionScope<T>

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> ErasedDestructor for T
where T: 'static,

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