module
motion
GSAP-style animation in the browser, driven by weft_motion.
use weft::web::motion::{self, Vars, Stagger};
motion::to(".card", Vars::new().set("y", -8).set("rotation", 2).duration(0.6).ease("back.out(2)"));
motion::timeline()
.from("h1", Vars::new().set("opacity", 0).set("y", 40), "")
.from(".feature", Vars::new().set("opacity", 0).stagger(Stagger::each(0.08)), "-=0.3")
.play();
motion::to(".hero img", Vars::new().set("scale", 1.2).scroll(motion::Scroll::new(".hero").scrub(1.0)));Templates can animate declaratively with motion* attributes (see weft_motion::MotionSpec); the DOM host binds them after each render.
Structs
- Animation
A running (or paused) tween or timeline.
- Scroll
A scroll trigger for a tween or timeline.
- TimelineBuilder
A sequence of tweens.
- Vars
Tween settings and properties, GSAP's
vars.
Enums
- Targets
What to animate.
Functions
bind_declarative
pub fn bind_declarative(root: &Element)Bind every declarative motion* animation under root, rebuilding any whose attributes changed. Called by the DOM host after each render.
bind_horizontal
pub fn bind_horizontal(root: &Element)Drive [data-hscroll] sections (HorizontalScroll): the viewport sticks while the page scrolls past, and the track slides sideways by the same distance. Without the runtime (or with reduced motion) the track simply scrolls horizontally.
from
pub fn from(targets: impl Into<Targets>, vars: Vars) -> AnimationAnimate from vars to the current values.
from_to
pub fn from_to(targets: impl Into<Targets>, from: Vars, to: Vars) -> AnimationAnimate from from's values to to's (timing comes from to).
replay
pub fn replay(root: &Element)Replay the declarative animations on root and inside it from the start (whatever their trigger).
to
pub fn to(targets: impl Into<Targets>, vars: Vars) -> AnimationAnimate from the current values to vars.
use_manual_clock
pub fn use_manual_clock(on: bool)Use a manual clock (frames only via tick); for tests.