pub struct MotionSpec {
pub duration_ms: u64,
pub delay_ms: u64,
pub curve: CubicBezier,
/* private fields */
}Expand description
A curve with a duration and a delay: everything one animation needs, taken from the token document rather than written beside the element.
A specification can carry a spring instead of a curve. Its duration is then
the spring’s settle time, so everything that already knows how to run a
specification — Transition,
Presence, Stagger and GPUI’s
with_animation — runs a spring without knowing it is one.
Fields§
§duration_ms: u64§delay_ms: u64§curve: CubicBezierImplementations§
Source§impl MotionSpec
impl MotionSpec
pub const fn new(duration_ms: u64, curve: CubicBezier) -> Self
Sourcepub fn sprung(spring: Spring) -> Self
pub fn sprung(spring: Spring) -> Self
A specification that arrives on a spring rather than along a curve.
The duration is the spring’s settle time, which is where the weight comes from: a spring is still moving after a curve of the same nominal length has stopped.
pub const fn with_delay(self, delay_ms: u64) -> Self
pub fn is_sprung(self) -> bool
Sourcepub fn spring(self) -> Option<Spring>
pub fn spring(self) -> Option<Spring>
The spring behind a sprung specification, for callers that need more of it than an eased fraction — velocity across a retarget, for one.
pub fn total(self) -> Duration
pub fn progress(self, raw: f32) -> f32
Sourcepub fn time_at(self, value: f32) -> Duration
pub fn time_at(self, value: f32) -> Duration
The earliest point in the run at which the specification has reached
value: the inverse of MotionSpec::progress, on the same clock.
Sampled at a millisecond rather than solved, because a cubic bezier has no closed-form inverse and a spring is not even monotonic — an underdamped one passes its target and comes back, so “the earliest time it was there” is the only well-defined answer. A millisecond is the granularity a specification is written in anyway.
A value never reached returns the whole run.
Sourcepub fn after(self, previous: MotionSpec) -> Self
pub fn after(self, previous: MotionSpec) -> Self
The specification moved to start when previous has finished.
Its own delay is kept and counted from there, so “80ms after the panel
has opened” is content.with_delay(80).after(panel) and the caller
never adds two numbers together. Sequence is the
same composition for more than two, and can report the total.
Sourcepub fn animation(self) -> Animation
pub fn animation(self) -> Animation
Adapts the specification to GPUI’s animation driver.
GPUI requires an eased delta inside 0..1, so an overshooting curve or
an underdamped spring is clamped here. Overshoot survives in
Transition and Presence,
which sample MotionSpec::progress directly.
pub fn repeating(self) -> Animation
Trait Implementations§
Source§impl Clone for MotionSpec
impl Clone for MotionSpec
Source§fn clone(&self) -> MotionSpec
fn clone(&self) -> MotionSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MotionSpec
Source§impl Debug for MotionSpec
impl Debug for MotionSpec
Source§impl PartialEq for MotionSpec
impl PartialEq for MotionSpec
impl StructuralPartialEq for MotionSpec
Auto Trait Implementations§
impl Freeze for MotionSpec
impl RefUnwindSafe for MotionSpec
impl Send for MotionSpec
impl Sync for MotionSpec
impl Unpin for MotionSpec
impl UnsafeUnpin for MotionSpec
impl UnwindSafe for MotionSpec
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