Expand description
GSAP animations for Autumn, with typed Rust builders and htmx support.
- Add
GsapPluginto the app. - Put
gsap_script()in the page<head>. - Animate with
Gsap,Timelineor rawdata-gsapattributes.
use std::time::Duration;
use autumn_plugin_gsap::{Gsap, GsapPlugin, Split, gsap_script};
use autumn_web::prelude::*;
#[get("/")]
async fn index() -> Markup {
html! {
html {
head { (gsap_script()) }
body {
(Gsap::fade_up().split(Split::Chars).wrap(html! { h1 { "Hello" } }))
p data-gsap="fade" data-gsap-delay="0.2" { "World" }
}
}
}
}
autumn_web::app()
.plugin(GsapPlugin::new())
.routes(routes![index])
.run()
.await;The crate vendors GSAP 3.15.0 with ScrollTrigger and SplitText. You need no npm and no bundler.
init.js reads the attributes on page load and on each htmx:load.
It reverts the animations of content that htmx removes.
When the user prefers reduced motion, elements do not animate.
The GSAP files use the GSAP Standard License. The plugin code uses Apache-2.0.
Structs§
- Gsap
- One declarative GSAP tween: a preset (or
Props) and options. - Gsap
Plugin - Installs the GSAP asset bundle (
GSAP_ASSETS). - Parallax
- A scroll-linked vertical drift (
data-gsap="parallax"). - Props
- Tween properties for
Gsap::from_props,Gsap::to_propsandGsap::from_to. - Timeline
- A GSAP timeline. It plays the
data-gsapchildren in document order, as one sequence. - Toggle
Actions - ScrollTrigger
toggleActions: what to do on enter, leave, enter back and leave back. - Upstream
File - One vendored upstream file.
Enums§
- Action
- One ScrollTrigger toggle action.
- Ease
- A GSAP ease. It writes the GSAP ease string, for example
power3.out. - EaseDir
- The direction of an
Easecurve. - Edge
- One edge in a
ScrollPos. - Play
- When an animation starts.
- Position
- The start time of a tween in a
Timeline(the GSAP position parameter). - Preset
- A preset start state. The element animates from this state to its CSS state.
- Repeat
- How many times an animation plays again after the first play.
- Scroll
Pos - A ScrollTrigger
startorendvalue. - Scrub
- ScrollTrigger
scrub: link the animation progress to the scroll position. - Split
- The text unit that SplitText animates.
- Stagger
From - Where a stagger starts.
- Tag
- The HTML element that
Gsap::wrap_in,Timeline::wrap_inandParallax::wrap_inwrite.
Constants§
- ASSETS_
NAMESPACE - URL namespace: files serve under
/static/_plugins/gsap/. - GSAP_
LICENSE - The GSAP license of the vendored files. The plugin code is Apache-2.0.
- GSAP_
UPSTREAM - The vendored upstream files, with their pinned hashes.
- GSAP_
VERSION - The vendored GSAP version.
- PLUGIN_
NAME - The plugin name in Autumn diagnostics.
Statics§
- GSAP_
ASSETS - The asset bundle: GSAP, ScrollTrigger, SplitText,
init.jsandgsap.css.
Functions§
- gsap_
script - Writes the deferred
<script>tags: GSAP, ScrollTrigger, SplitText, theninit.js. - gsap_
stylesheet - Writes the
<link>tag forgsap.css.
Type Aliases§
- Attr
- One HTML attribute: name and value. An empty value writes a bare attribute.