pub struct Transition<T: Interpolate> { /* private fields */ }Expand description
A value that animates toward whatever it is last told to be.
Retargeting starts from the value currently on screen rather than from the previous target, so an interrupted transition does not jump backward.
Implementations§
Source§impl<T: Interpolate> Transition<T>
impl<T: Interpolate> Transition<T>
Sourcepub fn new(value: T, spec: MotionSpec) -> Self
pub fn new(value: T, spec: MotionSpec) -> Self
Starts settled at value, so a first render does not animate in.
pub fn spec(self, spec: MotionSpec) -> Self
pub fn target(&self) -> T
pub fn value(&self) -> T
pub fn is_animating(&self) -> bool
Sourcepub fn set(&mut self, target: T)where
T: PartialEq,
pub fn set(&mut self, target: T)where
T: PartialEq,
Aims at a new target. Setting the current target again is a no-op, so a render that re-declares the same value does not restart the animation.
A retarget hands the motion on rather than restarting it: the speed the value already had is measured, converted into the new distance, and released into the new motion. Without that, a target changed mid-flight stalls the value for the first few frames of the new run.
The speed keeps its direction, so reversing a target throws the value on the way it was already going before it comes back. Turning it round on the spot would be the stall this exists to remove, wearing a different shape.
Sourcepub fn release(&mut self, target: T, velocity: f32)
pub fn release(&mut self, target: T, velocity: f32)
Aims at a new target with a speed the value did not get from an animation, which is what a value let go of by the hand has.
This is inertia. The gesture reports its speed — see
VelocityTracker — and the spring is
released with it rather than from a standstill, so a flicked thing
carries on and settles instead of stopping dead the instant the finger
leaves it. It is the same handover a retarget performs, with the speed
coming from outside instead of from the motion being interrupted.
velocity is in value units a second and positive toward target. A
release always restarts the motion, including at the current target: a
value thrown at where it already is has somewhere to go and come back
from.
Only a sprung specification can carry it. A curve has no momentum, so a
released curve is an ordinary Transition::set.
Sourcepub fn snap(&mut self, target: T)
pub fn snap(&mut self, target: T)
Jumps to target without animating, for state changes the user did not
cause, such as a theme switch.
pub fn advance(&mut self, delta: Duration)
Trait Implementations§
Source§impl<T: Clone + Interpolate> Clone for Transition<T>
impl<T: Clone + Interpolate> Clone for Transition<T>
Source§fn clone(&self) -> Transition<T>
fn clone(&self) -> Transition<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<T: Copy + Interpolate> Copy for Transition<T>
Source§impl<T: Debug + Interpolate> Debug for Transition<T>
impl<T: Debug + Interpolate> Debug for Transition<T>
Source§impl<T: PartialEq + Interpolate> PartialEq for Transition<T>
impl<T: PartialEq + Interpolate> PartialEq for Transition<T>
impl<T: PartialEq + Interpolate> StructuralPartialEq for Transition<T>
Auto Trait Implementations§
impl<T> Freeze for Transition<T>where
T: Freeze,
impl<T> RefUnwindSafe for Transition<T>where
T: RefUnwindSafe,
impl<T> Send for Transition<T>where
T: Send,
impl<T> Sync for Transition<T>where
T: Sync,
impl<T> Unpin for Transition<T>where
T: Unpin,
impl<T> UnsafeUnpin for Transition<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Transition<T>where
T: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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