Skip to main content

Crate autumn_plugin_gsap

Crate autumn_plugin_gsap 

Source
Expand description

GSAP animations for Autumn, with typed Rust builders and htmx support.

  1. Add GsapPlugin to the app.
  2. Put gsap_script() in the page <head>.
  3. Animate with Gsap, Timeline or raw data-gsap attributes.
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.
GsapPlugin
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_props and Gsap::from_to.
Timeline
A GSAP timeline. It plays the data-gsap children in document order, as one sequence.
ToggleActions
ScrollTrigger toggleActions: what to do on enter, leave, enter back and leave back.
UpstreamFile
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 Ease curve.
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.
ScrollPos
A ScrollTrigger start or end value.
Scrub
ScrollTrigger scrub: link the animation progress to the scroll position.
Split
The text unit that SplitText animates.
StaggerFrom
Where a stagger starts.
Tag
The HTML element that Gsap::wrap_in, Timeline::wrap_in and Parallax::wrap_in write.

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.js and gsap.css.

Functions§

gsap_script
Writes the deferred <script> tags: GSAP, ScrollTrigger, SplitText, then init.js.
gsap_stylesheet
Writes the <link> tag for gsap.css.

Type Aliases§

Attr
One HTML attribute: name and value. An empty value writes a bare attribute.