Struct Transition
pub struct Transition { /* private fields */ }Expand description
An interruptible open/close transition tracking a 0.0..=1.0 “openness”
so a surface animates in and out, and a mid-flight reversal
retargets from the current value instead of snapping to 0 first.
Implementations§
§impl Transition
impl Transition
pub fn closed() -> Transition
pub fn open() -> Transition
pub fn open() -> Transition
For surfaces that boot already shown.
pub fn modal_curve(&self, now: Instant, start_scale: f64) -> (f32, f64, f64)
pub fn modal_curve(&self, now: Instant, start_scale: f64) -> (f32, f64, f64)
(alpha, dy, scale) for a modal this transition drives, covering
both the enter (openness 0→1) and the exit (openness 1→0). The panel
starts 20 px low at start_scale and rises to rest on the enter; the
exit plays the same curve in reverse instead of the panel vanishing.
pub fn is_visible(&self, now: Instant) -> bool
pub fn is_visible(&self, now: Instant) -> bool
True while opening, open, or closing (openness > 0) — draw code
gates on this, not the raw intent bool, so the exit curve paints
instead of the panel vanishing.
pub fn is_open(&self) -> bool
pub fn is_open(&self) -> bool
The logical open/closed intent (the last set_open), independent
of whether the animation has settled.
pub fn is_animating(&self, now: Instant) -> bool
pub fn is_animating(&self, now: Instant) -> bool
True while the value is still moving — feeds needs_animation_frame.
pub fn set_open(&mut self, open: bool, duration: Duration, curve: Curve)
pub fn set_open(&mut self, open: bool, duration: Duration, curve: Curve)
No-op when the intent is unchanged AND the animation has settled, so repeated calls each frame don’t restart the curve.
pub fn set_open_at(
&mut self,
open: bool,
duration: Duration,
curve: Curve,
now: Instant,
)
pub fn set_open_at( &mut self, open: bool, duration: Duration, curve: Curve, now: Instant, )
Self::set_open against a caller-supplied clock.
Every other reader here — Self::value, Self::is_visible,
Self::is_animating — already takes now; set_open was the one
that reached for the clock itself. That asymmetry is untestable: a
test could start a transition and ask whether it was still running,
but the two calls read the clock independently, so a scheduler stall
longer than the animation between them let it finish and the
assertion flip. Pinning both ends to one instant makes such a test a
statement about the animation rather than about the machine’s load.
Trait Implementations§
§impl Clone for Transition
impl Clone for Transition
§fn clone(&self) -> Transition
fn clone(&self) -> Transition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for Transition
impl Debug for Transition
impl Copy for Transition
Auto Trait Implementations§
impl Freeze for Transition
impl RefUnwindSafe for Transition
impl Send for Transition
impl Sync for Transition
impl Unpin for Transition
impl UnsafeUnpin for Transition
impl UnwindSafe for Transition
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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