Skip to main content

Motion

Struct Motion 

Source
pub struct Motion { /* private fields */ }
Expand description

How a node animates. Attach it with BuildCx::motion.

use ravenrs_animation::Transition;
use ravenrs_core::Effect;
use ravenrs_widgets::Motion;

// Colors ease on hover; the node pops in and fades out.
let motion = Motion::new()
    .paint(Transition::fast())
    .enter(Effect::hidden().with_scale(0.96), Transition::snappy())
    .exit(Effect::hidden(), Transition::fast());

Implementations§

Source§

impl Motion

Source

pub const fn new() -> Self

Nothing animates yet.

Source

pub const fn paint(self, transition: Transition) -> Self

Eases this node’s own fill, border, shadow, corner radius and text color whenever a build changes them, like CSS transition. Colors travel through OKLab. Gradients and Paint::Custom change at once.

Source

pub const fn layout(self, transition: Transition) -> Self

Glides the node from its old frame to its new one when layout moves it. Its children travel with it. Input keeps using the final frame.

Source

pub const fn shared_layout( self, scope: WidgetId, tag: u64, transition: Transition, ) -> Self

Makes this node the same visual object as the node of a previous build with the same scope and tag, wherever it is now: a selection marker that slides from the old tab to the new one. scope is usually the widget id of the common parent.

Source

pub const fn surface_exit(self) -> Self

The exit fades this node as one surface: its content goes first, over the still solid panel, and then the panel. Opacity applies to each shape on its own, so fading all at once would show the panel through its fields, in a gray like metal. The panel must be the first thing the node paints.

Source

pub const fn shape_only(self) -> Self

With Self::layout, moves only the node’s own shape. Its children stay where layout put them.

Source

pub const fn underlay(self) -> Self

Paints the node’s own shape behind all its siblings, so a moving marker slides under the labels it crosses. The node must be a direct child of the container holding those siblings.

Source

pub const fn effect(self, effect: Effect, transition: Transition) -> Self

Eases the node and its subtree to this effect, such as a slight shrink while pressed. Layout and hit testing are unaffected.

Source

pub const fn enter(self, from: Effect, transition: Transition) -> Self

When the node first appears, it starts from this effect.

Source

pub const fn exit(self, to: Effect, transition: Transition) -> Self

When the node stops being built, its last picture stays on screen and plays this effect. The picture takes no input and is hidden from assistive technology: for the app, the node is already gone. Reopening during the exit reverses it from where it is.

Source

pub const fn key(self, key: u64) -> Self

The node’s identity among the motions of its view. Defaults to call order, so use it for nodes built in a loop whose items come and go.

Source

pub const fn anchored(self) -> Self

For the root of an overlay: scales around the point nearest its anchor, and a vertical offset flips when the overlay opened on the other side.

Trait Implementations§

Source§

impl Clone for Motion

Source§

fn clone(&self) -> Motion

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 Copy for Motion

Source§

impl Debug for Motion

Source§

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

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

impl Default for Motion

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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