Skip to main content

autumn_plugin_gsap/
lib.rs

1//! GSAP animations for Autumn, with typed Rust builders and htmx support.
2//!
3//! 1. Add [`GsapPlugin`] to the app.
4//! 2. Put [`gsap_script()`] in the page `<head>`.
5//! 3. Animate with [`Gsap`], [`Timeline`] or raw `data-gsap` attributes.
6//!
7//! ```rust,no_run
8//! use std::time::Duration;
9//! use autumn_plugin_gsap::{Gsap, GsapPlugin, Split, gsap_script};
10//! use autumn_web::prelude::*;
11//!
12//! #[get("/")]
13//! async fn index() -> Markup {
14//!     html! {
15//!         html {
16//!             head { (gsap_script()) }
17//!             body {
18//!                 (Gsap::fade_up().split(Split::Chars).wrap(html! { h1 { "Hello" } }))
19//!                 p data-gsap="fade" data-gsap-delay="0.2" { "World" }
20//!             }
21//!         }
22//!     }
23//! }
24//!
25//! # async fn run() {
26//! autumn_web::app()
27//!     .plugin(GsapPlugin::new())
28//!     .routes(routes![index])
29//!     .run()
30//!     .await;
31//! # }
32//! ```
33//!
34//! The crate vendors GSAP 3.15.0 with ScrollTrigger and SplitText. You need no npm and no bundler.
35//! `init.js` reads the attributes on page load and on each `htmx:load`.
36//! It reverts the animations of content that htmx removes.
37//! When the user prefers reduced motion, elements do not animate.
38//!
39//! The GSAP files use the [GSAP Standard License](https://gsap.com/standard-license).
40//! The plugin code uses Apache-2.0.
41
42mod assets;
43mod attrs;
44mod ease;
45mod fmt;
46#[cfg(test)]
47mod grammar;
48mod options;
49mod plugin;
50mod props;
51mod script;
52mod scroll;
53mod timeline;
54mod tween;
55
56pub use assets::{
57    ASSETS_NAMESPACE, GSAP_ASSETS, GSAP_LICENSE, GSAP_UPSTREAM, GSAP_VERSION, UpstreamFile,
58};
59pub use attrs::{Attr, Tag};
60pub use ease::{Ease, EaseDir};
61pub use options::Repeat;
62pub use plugin::{GsapPlugin, PLUGIN_NAME};
63pub use props::Props;
64pub use script::{gsap_script, gsap_stylesheet};
65pub use scroll::{Action, Edge, Play, ScrollPos, Scrub, ToggleActions};
66pub use timeline::{Position, Timeline};
67pub use tween::{Gsap, Parallax, Preset, Split, StaggerFrom};