Skip to content

crate

weft_motion

weft-motion

GSAP-style animation, as pure, testable Rust: the browser runtime in weft-web (and the 3D scene) read start values and apply the results.

  • Ease — every GSAP ease (power1–4, sine, expo, circ, back, elastic, bounce, steps, cubic-bezier) with .in, .out and .inOut.
  • interpolate — numbers with units, colours, relative values ("+=40") and compound strings such as shadows and filters.
  • Tween, Stagger, Timeline with labels and the position parameter ("<", ">", "+=0.5", "intro+=1"), repeat and yoyo.
  • ScrollTrigger — start/end lines, scrubbing and toggle actions.
  • MotionSpec — declarative motion* template attributes and presets.
  • Transform — x, y, rotation, scale, … composed into CSS.

Modules

  • ease

    Easing curves with GSAP's names: power1–power4 (and quad, cubic, quart, quint, strong), sine, expo, circ, back, elastic, bounce, steps(n), cubic-bezier(…) and none/linear, each with .in, .out (the default) and .inOut.

  • scroll

    ScrollTrigger maths: when an element crosses lines in the viewport, and how far through a scrubbed range the scroll is.

  • spec

    Declarative motion: the motion* template attributes, presets, and text splitting.

  • timeline

    Tweens, staggers and timelines — pure timing. Values are filled in by a runtime (the DOM, a 3D scene) which reads start values and applies Samples.

  • transform

    GSAP-style transform properties (x, y, rotation, scale, …) composed into one CSS transform, plus property-name helpers.

  • value

    Interpolating CSS-ish values the way GSAP does: numbers with units, colours (hex, rgb(), rgba(), hsl(), named), relative values ("+=40"), and compound strings ("0 0 20px rgba(0,0,0,.5)") whose numbers are tweened while the rest stays put.

Structs

  • Anchor

    A point on the trigger element or viewport: a fraction of its height plus pixels ("top" = 0, "center" = 0.5, "bottom" = 1, "80%", "100px", "center+=40").

  • Ease

    An easing function.

  • Edge

    "<trigger anchor> <viewport anchor>", e.g. "top 80%": the moment the trigger's top reaches 80% down the viewport.

  • Entry

    A timeline's child and where it starts.

  • MotionSpec

    A parsed declarative animation.

  • Prop

    One animated property: optional explicit start, and the end value. A missing from means "the current value"; a missing to (a from() tween) means "back to the current value".

  • Sample

    A value to apply: target target of tween tween gets prop = value.

  • ScrollTrigger

    When a scroll-triggered animation plays: where it starts and ends in the viewport, whether it's scrubbed, and what each crossing does.

  • Stagger

    GSAP's stagger: a delay between targets (each) or spread over a total (amount), from a point in the list or a grid, optionally eased.

  • Timeline

    A sequence of tweens with labels, repeat and yoyo.

  • Transform

    One element's transform state.

  • Tween

    A tween over count targets.

Enums

  • Action

    What to do on each crossing (GSAP's toggleActions).

  • Crossing

    A crossing of the start or end line.

  • Curve

    The shape of an easing curve, before its direction is applied.

  • Dir

    Which end of an easing curve eases: the start (In), the end (Out) or both (InOut).

  • From

    Where a staggered sequence starts from.

  • Position

    GSAP's position parameter.

  • SplitBy

    How to split text for per-character or per-word animation.

  • Trigger

    When a declarative animation runs.

Functions

canonical

pub fn canonical(prop: &str) -> &str

The canonical transform name for an alias (rotate → rotation).

interpolate

pub fn interpolate(from: &str, to: &str, progress: f64) -> String

The value progress of the way from from to to (both strings). Numbers (and colours) are interpolated when the two have the same shape; a unitless side adopts the other side's units (0 → 40px). Otherwise the value jumps to to at the end.

is_transform

pub fn is_transform(prop: &str) -> bool

Whether prop is part of transform (x, rotate, scale…), in any of its spellings.

kebab

pub fn kebab(prop: &str) -> String

backgroundColor → background-color (custom properties untouched).

parse_color

pub fn parse_color(s: &str) -> Option<[f64; 4]>

Parse any supported colour to [r, g, b, a].

parse_props

pub fn parse_props(s: &str) -> Vec<(String, String)>

"opacity: 0; y: 40px, rotation: -10" → [("opacity","0"), …]. Pairs are separated by ; (or by , outside parentheses).

preset_names

pub fn preset_names() -> Vec<&'static str>

Names of the built-in presets.

resolve_relative

pub fn resolve_relative(current: &str, target: &str) -> String

Resolve a relative value ("+=40", "-=10px", "*=2") against the current value; other values are returned as they are.

shape

pub fn shape(s: &str) -> Shape

Split a value into literal text and numbers.

split_text

pub fn split_text(text: &str, by: SplitBy) -> Vec<(String, bool)>

Split text into animatable pieces; whitespace is kept as its own pieces (marked false) so spacing survives inline-block layout.

Constants

TRANSFORM_PROPS

pub const TRANSFORM_PROPS: &[(&str, f64, &str)] = _;

Transform components and their defaults and units.