Position

Enum Position 

Source
pub enum Position {
    Absolute(f32),
    Relative(f32),
    Label(String),
    AfterPrevious,
    WithPrevious,
    Start,
    End,
}
Expand description

Specifies when a child animation starts within a timeline.

Similar to GSAP’s position parameter, this allows for:

  • Sequential animations (one after another)
  • Parallel animations (starting together)
  • Overlapping animations (one starts before another ends)
  • Labeled positions (named time markers)

§Examples

use eazy_tweener::Position;

// Add at 2 seconds from timeline start
let pos = Position::Absolute(2.0);

// Add 0.5 seconds after previous animation ends
let pos = Position::Relative(0.5);

// Overlap with previous animation by 0.3 seconds
let pos = Position::Relative(-0.3);

// Start at the same time as previous animation
let pos = Position::WithPrevious;

Variants§

§

Absolute(f32)

Start at an absolute time from the timeline’s beginning.

Absolute(2.0) means start at 2 seconds.

§

Relative(f32)

Start relative to the end of the previous animation.

Relative(0.5) means start 0.5 seconds after previous ends. Relative(-0.3) means start 0.3 seconds before previous ends (overlap).

§

Label(String)

Start at a named label position.

Labels must be added to the timeline before referencing them.

§

AfterPrevious

Start at the same time the previous animation ends (sequential).

This is the default behavior - equivalent to Relative(0.0).

§

WithPrevious

Start at the same time as the previous animation (parallel).

Useful for animating multiple properties simultaneously.

§

Start

Start at the beginning of the timeline.

§

End

Start at the current end of the timeline.

Implementations§

Source§

impl Position

Source

pub fn resolve( &self, previous_end: f32, previous_start: f32, timeline_end: f32, labels: &HashMap<String, f32, FxBuildHasher>, ) -> Option<f32>

Calculate the absolute start time for this position.

§Parameters
  • previous_end: End time of the previous child (0.0 if first child)
  • previous_start: Start time of the previous child (0.0 if first child)
  • timeline_end: Current total duration of the timeline
  • labels: Map of label names to their time positions
§Returns

The absolute start time in seconds, or None if label not found.

Source

pub fn is_absolute(&self) -> bool

Check if this position is absolute (not relative to other animations).

Source

pub fn is_relative(&self) -> bool

Check if this position is relative to the previous animation.

Trait Implementations§

Source§

impl Clone for Position

Source§

fn clone(&self) -> Position

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Position

Source§

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

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

impl Default for Position

Source§

fn default() -> Position

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

impl From<&str> for Position

Source§

fn from(s: &str) -> Position

Converts to this type from the input type.
Source§

impl From<String> for Position

Source§

fn from(s: String) -> Position

Converts to this type from the input type.
Source§

impl From<f32> for Position

Source§

fn from(time: f32) -> Position

Converts to this type from the input type.
Source§

impl PartialEq for Position

Source§

fn eq(&self, other: &Position) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Position

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.