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
impl Position
Sourcepub fn resolve(
&self,
previous_end: f32,
previous_start: f32,
timeline_end: f32,
labels: &HashMap<String, f32, FxBuildHasher>,
) -> Option<f32>
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 timelinelabels: Map of label names to their time positions
§Returns
The absolute start time in seconds, or None if label not found.
Sourcepub fn is_absolute(&self) -> bool
pub fn is_absolute(&self) -> bool
Check if this position is absolute (not relative to other animations).
Sourcepub fn is_relative(&self) -> bool
pub fn is_relative(&self) -> bool
Check if this position is relative to the previous animation.