pub enum Animation {
Default,
Bezier {
duration: Duration,
x1: f32,
y1: f32,
x2: f32,
y2: f32,
},
Spring {
stiffness: f32,
damping: f32,
},
}Expand description
An enumeration representing different types of animations
This enum exposes two native animation primitives:
Bezier: Timed animations represented by cubic bezier control pointsSpring: Physics-based movement with configurable stiffness and damping
Convenience constructors (linear, ease_in, etc.) all map to Bezier.
Variants§
Default
Default animation behavior (uses system defaults)
Bezier
Timed cubic bezier animation with control points (x1, y1, x2, y2)
Fields
Spring
Spring animation with physics-based movement
Implementations§
Source§impl Animation
impl Animation
Sourcepub const fn linear(duration: Duration) -> Self
pub const fn linear(duration: Duration) -> Self
Creates a new Linear animation with the specified duration
§Examples
use waterui_core::animation::Animation;
use core::time::Duration;
let animation = Animation::linear(Duration::from_millis(300)); // 300ms
let animation = Animation::linear(Duration::from_secs(1)); // 1 secondSourcepub const fn ease_in(duration: Duration) -> Self
pub const fn ease_in(duration: Duration) -> Self
Creates a new ease-in animation with the specified duration
§Examples
use waterui_core::animation::Animation;
use core::time::Duration;
let animation = Animation::ease_in(Duration::from_millis(300)); // 300ms
let animation = Animation::ease_in(Duration::from_secs(1)); // 1 secondSourcepub const fn ease_out(duration: Duration) -> Self
pub const fn ease_out(duration: Duration) -> Self
Creates a new ease-out animation with the specified duration
§Examples
use waterui_core::animation::Animation;
use core::time::Duration;
let animation = Animation::ease_out(Duration::from_millis(300)); // 300ms
let animation = Animation::ease_out(Duration::from_secs(1)); // 1 secondSourcepub const fn ease_in_out(duration: Duration) -> Self
pub const fn ease_in_out(duration: Duration) -> Self
Creates a new ease-in-out animation with the specified duration
§Examples
use waterui_core::animation::Animation;
use core::time::Duration;
let animation = Animation::ease_in_out(Duration::from_millis(300)); // 300ms
let animation = Animation::ease_in_out(Duration::from_secs(1)); // 1 secondSourcepub const fn bezier(
duration: Duration,
x1: f32,
y1: f32,
x2: f32,
y2: f32,
) -> Self
pub const fn bezier( duration: Duration, x1: f32, y1: f32, x2: f32, y2: f32, ) -> Self
Creates a new custom cubic bezier animation
Control points define the shape of the easing curve. Standard curves can be created with these control points:
- Linear: (0.0, 0.0, 1.0, 1.0)
- Ease-in: (0.42, 0.0, 1.0, 1.0)
- Ease-out: (0.0, 0.0, 0.58, 1.0)
- Ease-in-out: (0.42, 0.0, 0.58, 1.0)
§Examples
use waterui_core::animation::Animation;
use core::time::Duration;
// Custom bounce-like curve
let animation = Animation::bezier(Duration::from_millis(400), 0.25, 0.1, 0.25, 1.0);§Panics
Panics if any control point is non-finite or if x1 or x2 falls
outside the normalized [0, 1] range.
Sourcepub const fn curve(&self) -> EasingCurve
pub const fn curve(&self) -> EasingCurve
Get the underlying easing curve for this animation.
This allows using the unified easing system for interpolation.
Sourcepub const fn duration(&self) -> Duration
pub const fn duration(&self) -> Duration
Get the total duration of this animation.
For spring animations, returns a default duration (600ms) since spring duration depends on the physics parameters.
Sourcepub fn progress(&self, elapsed: Duration) -> f32
pub fn progress(&self, elapsed: Duration) -> f32
Get the eased progress for the given elapsed time.
Returns a value typically between 0.0 and 1.0, though spring animations may temporarily overshoot (return values > 1.0 or < 0.0).
§Arguments
elapsed- Time elapsed since animation started
Sourcepub fn interpolate<T: Animatable>(
&self,
from: &T,
to: &T,
elapsed: Duration,
) -> T
pub fn interpolate<T: Animatable>( &self, from: &T, to: &T, elapsed: Duration, ) -> T
Interpolate between two values based on elapsed time.
Uses the animation’s easing curve to calculate the current value.
§Examples
use waterui_core::animation::Animation;
use core::time::Duration;
let anim = Animation::ease_in_out(Duration::from_millis(300));
let elapsed = Duration::from_millis(150); // halfway through
let value = anim.interpolate(&0.0_f32, &100.0_f32, elapsed);
// value is approximately 50.0, but easedSourcepub fn is_complete(&self, elapsed: Duration) -> bool
pub fn is_complete(&self, elapsed: Duration) -> bool
Returns true if the animation is complete.
An animation is complete when the elapsed time equals or exceeds its duration.
Trait Implementations§
Source§impl Signal for Animation
impl Signal for Animation
impl StructuralPartialEq for Animation
Auto Trait Implementations§
impl Freeze for Animation
impl RefUnwindSafe for Animation
impl Send for Animation
impl Sync for Animation
impl Unpin for Animation
impl UnsafeUnpin for Animation
impl UnwindSafe for Animation
Blanket Implementations§
Source§impl<S> AnimationExt for Swhere
S: SignalExt,
impl<S> AnimationExt for Swhere
S: SignalExt,
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,
Source§impl<T> IdentifiableExt for T
impl<T> IdentifiableExt for T
Source§impl<C, Output> IntoComputed<Output> for C
impl<C, Output> IntoComputed<Output> for C
Source§fn into_computed(self) -> Computed<Output>
fn into_computed(self) -> Computed<Output>
Convert this value into a Computed<Output>.
Source§impl<C, Output> IntoSignal<Output> for C
impl<C, Output> IntoSignal<Output> for C
Source§impl<C> SignalExt for Cwhere
C: Signal,
impl<C> SignalExt for Cwhere
C: Signal,
Source§fn map<F, Output>(&self, f: F) -> Map<Self, F, Output>
fn map<F, Output>(&self, f: F) -> Map<Self, F, Output>
Source§fn zip<B>(&self, b: &B) -> Zip<Self, B>
fn zip<B>(&self, b: &B) -> Zip<Self, B>
Source§fn cached(&self) -> Cached<Self>
fn cached(&self) -> Cached<Self>
Source§fn computed(&self) -> Computed<Self::Output>where
Self: 'static,
fn computed(&self) -> Computed<Self::Output>where
Self: 'static,
Computed container.Source§fn with<T>(&self, metadata: T) -> WithMetadata<Self, T>where
T: 'static,
fn with<T>(&self, metadata: T) -> WithMetadata<Self, T>where
T: 'static,
Source§fn map_into<U>(&self) -> Map<Self, fn(Self::Output) -> U, U>
fn map_into<U>(&self) -> Map<Self, fn(Self::Output) -> U, U>
Into::into.Source§fn inspect<F>(
&self,
f: F,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, Self::Output>
fn inspect<F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, Self::Output>
Source§fn distinct(&self) -> Distinct<Self>
fn distinct(&self) -> Distinct<Self>
Source§fn equal_to(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
fn equal_to( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
true if the value equals the given value. Read moreSource§fn condition<F>(
&self,
predicate: F,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
fn condition<F>( &self, predicate: F, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
true if the predicate returns true for the value.Source§fn gt(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
fn gt( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
true if the value is greater than the given value.Source§fn lt(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
fn lt( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
true if the value is less than the given value.Source§fn ge(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
fn ge( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
true if the value is greater than or equal to the given value.Source§fn le(
&self,
other: Self::Output,
) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
fn le( &self, other: Self::Output, ) -> Map<Self, impl Clone + Fn(Self::Output) + 'static, bool>
true if the value is less than or equal to the given value.Source§fn is_some<T>(&self) -> Map<Self, fn(Option<T>) -> bool, bool>
fn is_some<T>(&self) -> Map<Self, fn(Option<T>) -> bool, bool>
true if the Option is Some.Source§fn is_none<T>(&self) -> Map<Self, fn(Option<T>) -> bool, bool>
fn is_none<T>(&self) -> Map<Self, fn(Option<T>) -> bool, bool>
true if the Option is None.Source§fn unwrap_or<T>(
&self,
default: T,
) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, T>
fn unwrap_or<T>( &self, default: T, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, T>
Source§fn unwrap_or_else<T, F>(
&self,
default: F,
) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, T>
fn unwrap_or_else<T, F>( &self, default: F, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, T>
Source§fn unwrap_or_default<T>(&self) -> Map<Self, fn(Option<T>) -> T, T>
fn unwrap_or_default<T>(&self) -> Map<Self, fn(Option<T>) -> T, T>
Source§fn some_equal_to<T>(
&self,
value: T,
) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, bool>
fn some_equal_to<T>( &self, value: T, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, bool>
true if the Option is Some and the value equals the given value.Source§fn flatten<T>(&self) -> Map<Self, fn(Option<Option<T>>) -> Option<T>, Option<T>>
fn flatten<T>(&self) -> Map<Self, fn(Option<Option<T>>) -> Option<T>, Option<T>>
Option<Option<T>> into Option<T>.Source§fn map_some<T, U, F>(
&self,
f: F,
) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, Option<U>>
fn map_some<T, U, F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, Option<U>>
Option<T> to Option<U> using the provided function.Source§fn and_then_some<T, U, F>(
&self,
f: F,
) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, Option<U>>
fn and_then_some<T, U, F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Option<T>) + 'static, Option<U>>
None if the option is None, otherwise calls f with the wrapped value and returns the result.Source§fn not(&self) -> Map<Self, fn(bool) -> bool, bool>
fn not(&self) -> Map<Self, fn(bool) -> bool, bool>
Source§fn and<B>(&self, other: &B) -> Map<Zip<Self, B>, fn((bool, bool)) -> bool, bool>
fn and<B>(&self, other: &B) -> Map<Zip<Self, B>, fn((bool, bool)) -> bool, bool>
Source§fn or<B>(&self, other: &B) -> Map<Zip<Self, B>, fn((bool, bool)) -> bool, bool>
fn or<B>(&self, other: &B) -> Map<Zip<Self, B>, fn((bool, bool)) -> bool, bool>
Source§fn then_some<T>(
&self,
value: T,
) -> Map<Self, impl Clone + Fn(bool) + 'static, Option<T>>
fn then_some<T>( &self, value: T, ) -> Map<Self, impl Clone + Fn(bool) + 'static, Option<T>>
Some(value) if true, otherwise None.Source§fn select<T>(
&self,
if_true: T,
if_false: T,
) -> Map<Self, impl Clone + Fn(bool) + 'static, T>
fn select<T>( &self, if_true: T, if_false: T, ) -> Map<Self, impl Clone + Fn(bool) + 'static, T>
if_true if true, otherwise if_false.Source§fn sign<T>(&self) -> Map<Self, fn(T) -> bool, bool>
fn sign<T>(&self) -> Map<Self, fn(T) -> bool, bool>
true if the value is not negative (i.e., positive or zero).Source§fn is_positive<T>(&self) -> Map<Self, fn(T) -> bool, bool>
fn is_positive<T>(&self) -> Map<Self, fn(T) -> bool, bool>
true if the value is positive.Source§fn is_negative<T>(&self) -> Map<Self, fn(T) -> bool, bool>
fn is_negative<T>(&self) -> Map<Self, fn(T) -> bool, bool>
true if the value is negative.Source§fn is_ok<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> bool, bool>
fn is_ok<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> bool, bool>
true if the Result is Ok.Source§fn is_err<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> bool, bool>
fn is_err<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> bool, bool>
true if the Result is Err.Source§fn ok<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> Option<T>, Option<T>>
fn ok<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> Option<T>, Option<T>>
Result<T, E> to Option<T>.Source§fn err<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> Option<E>, Option<E>>
fn err<T, E>(&self) -> Map<Self, fn(Result<T, E>) -> Option<E>, Option<E>>
Result<T, E> to Option<E>.Source§fn unwrap_or_result<T, E>(
&self,
default: T,
) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, T>
fn unwrap_or_result<T, E>( &self, default: T, ) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, T>
Ok value or a default.Source§fn unwrap_or_else_result<T, E, F>(
&self,
f: F,
) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, T>
fn unwrap_or_else_result<T, E, F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, T>
Ok value or computes it from the error.Source§fn map_ok<T, E, U, F>(
&self,
f: F,
) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, Result<U, E>>
fn map_ok<T, E, U, F>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, Result<U, E>>
Result<T, E> to Result<U, E> using the provided function.Source§fn map_err<T, E, F, U>(
&self,
f: F,
) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, Result<T, U>>
fn map_err<T, E, F, U>( &self, f: F, ) -> Map<Self, impl Clone + Fn(Result<T, E>) + 'static, Result<T, U>>
Result<T, E> to Result<T, F> using the provided function.Source§fn debounce(&self, duration: Duration) -> Debounce<Self, DefaultExecutor>
fn debounce(&self, duration: Duration) -> Debounce<Self, DefaultExecutor>
Source§fn throttle(&self, duration: Duration) -> Throttle<Self, DefaultExecutor>
fn throttle(&self, duration: Duration) -> Throttle<Self, DefaultExecutor>
Source§fn str_is_empty<T>(&self) -> Map<Self, fn(T) -> bool, bool>
fn str_is_empty<T>(&self) -> Map<Self, fn(T) -> bool, bool>
true if the string is empty. Read more