Skip to content

struct

Timeline

pub struct Timeline {
    pub entries: Vec<Entry>,
    pub labels: HashMap<String, f64>,
    pub repeat: i32,
    pub yoyo: bool,
    pub repeat_delay: f64,
}

A sequence of tweens with labels, repeat and yoyo.

Fields

entries

pub entries: Vec<Entry>

The tweens and where each starts.

labels

pub labels: HashMap<String, f64>

Named points in time, in seconds.

repeat

pub repeat: i32

How many more times it plays (-1: forever).

yoyo

pub yoyo: bool

Whether each repeat plays backwards from the last.

repeat_delay

pub repeat_delay: f64

Seconds between repeats.

Methods

new

pub fn new() -> Timeline

An empty timeline.

end

pub fn end(&self) -> f64

Where the timeline currently ends (the latest child end).

add

pub fn add(&mut self, tween: Tween, position: &str) -> f64

Add a tween at a position (see [Position::parse]); returns its start time.

add_label

pub fn add_label(&mut self, name: &str, position: &str) -> f64

Put a label at a position.

duration

pub fn duration(&self) -> f64

One cycle's length.

total_duration

pub fn total_duration(&self) -> f64

Length including repeats (infinite when repeating forever).

local_time

pub fn local_time(&self, t: f64) -> f64

Map a playhead time to a time within one cycle (handling repeat and yoyo).

sample

pub fn sample(&self, t: f64) -> Vec<Sample>

Every value at playhead time t. Targets of tweens that haven't started yet are left alone, except from values which apply immediately (as in GSAP, so content doesn't flash before it animates).

sample_entry

pub fn sample_entry(&self, k: usize, t: f64) -> Vec<Sample>

The values of one child at playhead time t (see [Timeline::sample]). Runtimes render children in order, resolving each one's start values just before, so a tween picks up where the previous one left off.

Trait implementations