Skip to main content

PropertyTransition

Struct PropertyTransition 

Source
pub struct PropertyTransition<K: TransitionValueKind>
where K::Inner: Copy + PartialEq,
{ /* private fields */ }
Expand description

Tracks one visual property and starts a transition when its target value changes.

The first observed value becomes the stable target baseline and does not start an animation. Later different values register a two-keyframe animation from the previous visual result to the new target value.

use aura_anim_iced::{
    AnimationRuntime, AnimationTargetId, Duration, OPACITY, PropertyTransition,
    PropertyValue, Timing,
};

let mut runtime = AnimationRuntime::testing();
let target = AnimationTargetId::new();
let mut opacity = PropertyTransition::new(target, OPACITY)
    .with_timing(Timing::new(100.0));

opacity.transition_to(&mut runtime, 0.0);
let first = opacity.transition_to(&mut runtime, 1.0).unwrap();

runtime.clock_mut().set_now(Duration::from_millis(40.0));
runtime.tick();

// Retargeting starts from the active animation's sampled visual value.
let retargeted = opacity.retarget_to(&mut runtime, 0.25).unwrap();
assert_eq!(retargeted.replaced(), Some(first.handle()));

let start = retargeted.registration().properties().unwrap();
let entry = start.find_property(&OPACITY.raw()).unwrap();
assert!(matches!(entry.value(), PropertyValue::Scalar(value) if (*value - 0.4).abs() < 0.001));

Implementations§

Source§

impl<K> PropertyTransition<K>

Source

pub fn new(target: AnimationTargetId, property: PropertySpec<K>) -> Self

Creates a property transition tracker with default timing.

Source

pub const fn from_rule( target: AnimationTargetId, rule: &BehaviorRule<K>, ) -> Self

Creates a property transition tracker from a reusable behavior rule.

Source

pub const fn with_timing(self, timing: Timing) -> Self

Replaces the timing used for newly registered transitions.

Source

pub const fn target(&self) -> AnimationTargetId

Returns the target that receives transition animations.

Source

pub const fn property(&self) -> PropertySpec<K>

Returns the tracked property.

Source

pub const fn timing(&self) -> Timing

Returns the timing used for newly registered transitions.

Source

pub const fn current_value(&self) -> Option<K::Inner>

Returns the last target value observed by this tracker.

Source

pub const fn active_handle(&self) -> Option<AnimationHandle>

Returns the active runtime handle created by this tracker, if any.

Source

pub fn is_active<C: AnimationClock>( &self, runtime: &AnimationRuntime<C>, ) -> bool

Returns whether this tracker currently owns a runtime animation handle.

Source

pub fn handle_completion<C: AnimationClock>( &mut self, runtime: &AnimationRuntime<C>, ) -> bool

Clears this tracker’s active handle when it appears in completed output.

Returns true when this transition handled its own completion.

Source

pub const fn active_transition(&self) -> Option<&ActivePropertyTransition<K>>

Returns metadata for the active property transition, if any.

Source

pub fn active_progress_at( &self, timestamp: Duration, ) -> Option<PropertyTransitionProgress<K>>

Returns sampled progress for the active transition at timestamp.

Source

pub fn transition_to<C: AnimationClock>( &mut self, runtime: &mut AnimationRuntime<C>, value: K::Inner, ) -> Option<PropertyTransitionRegistration>

Observes a new target value and registers an animation when it changed.

Returns None when the value only seeded the baseline or did not change. If a previous transition is still running, the replacement starts from that transition’s last sampled visual value.

Source

pub fn transition_from_visual<C: AnimationClock>( &mut self, runtime: &mut AnimationRuntime<C>, visual: K::Inner, value: K::Inner, ) -> Option<PropertyTransitionRegistration>

Observes a new target value with an explicit current visual value.

This is useful when application code already stores the rendered value from the latest tick. The registered animation starts from visual even if the previous target or runtime handle no longer represents what is currently on screen.

Source

pub fn retarget_to<C: AnimationClock>( &mut self, runtime: &mut AnimationRuntime<C>, value: K::Inner, ) -> Option<PropertyTransitionRegistration>

Retargets a currently running transition to a new destination.

Returns None when there is no active runtime animation, the active handle is stale, or the new destination is already the current target. The replacement animation starts from the active animation’s last sampled visual value.

Source

pub fn interrupt_from_visual<C: AnimationClock>( &mut self, runtime: &mut AnimationRuntime<C>, visual: K::Inner, value: K::Inner, ) -> Option<PropertyTransitionRegistration>

Interrupts the current transition and continues from an explicit visual value.

Unlike transition_from_visual, this method can replace an active animation even when value is already the current target. This is useful when an external interaction interrupts playback and application code wants the replacement animation to start from the exact value currently rendered on screen.

Trait Implementations§

Source§

impl<K: Clone + TransitionValueKind> Clone for PropertyTransition<K>
where K::Inner: Copy + PartialEq + Clone,

Source§

fn clone(&self) -> PropertyTransition<K>

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<K: Debug + TransitionValueKind> Debug for PropertyTransition<K>
where K::Inner: Copy + PartialEq + Debug,

Source§

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

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

impl<K: PartialEq + TransitionValueKind> PartialEq for PropertyTransition<K>
where K::Inner: Copy + PartialEq + PartialEq,

Source§

fn eq(&self, other: &PropertyTransition<K>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<K: TransitionValueKind> StructuralPartialEq for PropertyTransition<K>
where K::Inner: Copy + PartialEq,

Auto Trait Implementations§

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<State, Message> IntoBoot<State, Message> for State

Source§

fn into_boot(self) -> (State, Task<Message>)

Turns some type into the initial state of some Application.
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> MaybeClone for T

Source§

impl<T> MaybeDebug for T

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,