pub enum TransitionDriver {
Auto(AnimationController),
Held {
value: f64,
},
Settle {
spring: Spring,
target: f64,
elapsed: f64,
last: Option<FrameTime>,
},
}Expand description
The page-transition resolve/drive path: the framework’s own reduce- motion collapse policy, re-exported so an app-authored animation reuses it rather than re-deriving it.
resolve_spec applies Theme.motion.reduce_motion‘s hard accessibility
rule to a TransitionSpec — collapsing any animated preset to a
≤120ms linear cross-fade — and resolves a bare Timing::ThemeDefault
against the active MotionScheme. make_driver then turns the
resolved Timing into a running TransitionDriver (advanced each
frame via TransitionDriver::advance) plus the SpringDesc to settle it
with later (an interactive edge-swipe’s release fling). This is exactly
the pair frust-widgets’ own navigator and
motion::switcher::PatternSwitcher
drive their transitions through — before this re-export, an app widget
implementing its own page/dialog animation had to hand-roll the
reduce-motion collapse (read Theme.motion.reduce_motion, apply the
120ms + linear + zero-motion rule) instead of calling the framework’s one
implementation, so the two would silently drift the next time the
framework’s rule changes.
Not otherwise re-exported at frust-widgets’ own crate root (reached here
via frust_widgets::nav::transition, a pub mod two levels down) — this
is the facade’s job precisely so app code never has to know that.
use frust::{Curve, PageTransition, Theme, Timing, TransitionDriver, TransitionSpec};
// A theme with reduce_motion on: resolve_spec collapses the spec to the
// framework's own linear cross-fade, with no app-side collapse logic.
let mut theme = Theme::neutral();
theme.motion.reduce_motion = true;
let spec = TransitionSpec::duration(PageTransition::SlideUp);
let resolved = frust::resolve_spec(spec, Some(&theme.motion));
assert_eq!(resolved.preset, PageTransition::ReducedCrossfade);
assert_eq!(
resolved.timing,
Timing::Duration(std::time::Duration::from_millis(120), Curve::Linear)
);
let (driver, _settle_spring) = frust::make_driver(resolved.timing);
assert!(matches!(driver, TransitionDriver::Auto(_)));Drives a transition’s 0.0..=1.0 progress. The programmatic push/pop path
uses Auto (an AnimationController advanced during paint);
the Held/Settle variants are the seam the
interactive edge-swipe gesture drives (set_progress/settle on the navigator).
Variants§
Auto(AnimationController)
Programmatic drive: an AnimationController (duration or spring fling)
advanced from the frame clock.
Held
Externally pinned progress (drag-in-progress): paint reads value
verbatim and never advances; the transition stays alive (paused).
Settle
A released spring settle (fling): an analytic Spring released
from the held value toward target, advanced by frame-time differencing.
Implementations§
Trait Implementations§
Source§impl Clone for TransitionDriver
impl Clone for TransitionDriver
Source§fn clone(&self) -> TransitionDriver
fn clone(&self) -> TransitionDriver
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 TransitionDriver
Auto Trait Implementations§
impl Freeze for TransitionDriver
impl RefUnwindSafe for TransitionDriver
impl Send for TransitionDriver
impl Sync for TransitionDriver
impl Unpin for TransitionDriver
impl UnsafeUnpin for TransitionDriver
impl UnwindSafe for TransitionDriver
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.