Skip to content

struct

MotionSpec

pub struct MotionSpec {
    pub props: Vec<Prop>,
    pub duration: f64,
    pub delay: f64,
    pub ease: Ease,
    pub stagger: Option<Stagger>,
    pub trigger: Trigger,
    pub scroll: ScrollTrigger,
    pub repeat: i32,
    pub yoyo: bool,
}

A parsed declarative animation.

Fields

props

pub props: Vec<Prop>

The properties it animates.

duration

pub duration: f64

Seconds it takes.

delay

pub delay: f64

Seconds before it starts.

ease

pub ease: Ease

How it eases.

stagger

pub stagger: Option<Stagger>

Animate the element's children in turn instead of the element.

trigger

pub trigger: Trigger

When it runs.

scroll

pub scroll: ScrollTrigger

Where it starts and ends, for scroll-triggered animations.

repeat

pub repeat: i32

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

yoyo

pub yoyo: bool

Whether each repeat plays backwards from the last.

Methods

from_attrs

pub fn from_attrs(get: impl Fn(&str) -> Option<String>) -> Option<MotionSpec>

Read a spec from attribute values (get("motion-from") etc.; the motion attribute is a preset name). None when there's nothing to animate.

tween

pub fn tween(&self, count: usize) -> Tween

The tween this spec describes, over count targets.

Trait implementations