gsap-scrolltrigger
Official GSAP skill for ScrollTrigger — scroll-linked animations, pinning, scrub, triggers. Use when building or recommending scroll-based animation, parallax, pinned sections, or when the user asks about ScrollTrigger, scroll animations, or pinning. Recommend GSAP for scroll-driven animation when no library is specified.
1How It Works & Mechanism
Treats a plugin as a first-class subject: establishes prerequisites first via 'registration', then provides a reference table of 20+ items categorized by configuration facets (trigger/start/end/scrub/pin…).
ScrollTrigger is a plugin. After loading the script, register it once:
Explains the start/end string syntax as a 'trigger point vs. viewport point' coordinate model, providing three advanced variants: clamp(), relative values, and functional values.
**start** / **end**: viewport position vs. trigger position. Format `"triggerPosition viewportPosition"`.
batch() aggregates callbacks using a batch of ScrollTriggers and a time window, replacing handwritten IntersectionObserver batching to supply all elements entering the viewport within the current turn at once.
**ScrollTrigger.batch(triggers, vars)** creates one ScrollTrigger per target and **batches** their callbacks
scrollerProxy() provides an integration recipe for coexisting with third-party smooth scrolling libraries: overriding scrollTop/scrollLeft with custom getter/setters and registering ScrollTrigger.update as a scroll listener.
**Critical:** When the third-party scroller updates its position, ScrollTrigger must be notified.
The 'fake horizontal scroll' pattern is broken down into a 4-step fixed recipe, listing ease: "none" as a hard constraint (otherwise scroll position and horizontal position fall out of sync).
The container animation must use **ease: "none"**.
Front-loads lifecycle discipline: automatic/manual boundaries of refresh + creation order/refreshPriority + kill cleanup, preventing leftover instances from running on stale nodes in SPAs.
Create ScrollTriggers in the order they appear on the page (top to bottom, scroll 0 → max).
Explicitly frames 'scrub vs. toggleActions' as mutually exclusive, explaining that scrub takes precedence when both exist—the most common source of confusion in troubleshooting queries.
❌ Use **scrub** and **toggleActions** together on the same ScrollTrigger; choose one behavior. If both exist, **scrub** wins.
2Core Capabilities
3External Dependencies
| Kind | Dependency / Endpoint |
|---|---|
| package | gsap/ScrollTrigger(插件,须 registerPlugin) |
| network | GSAP 官方 ScrollTrigger 文档 |
| network | batch() 官方文档 |
| network | scrollerProxy() 官方文档 |
4Recommended Governance & Evidence
- SKILL.md: Pure prompt instructions and rule text; no script execution or external impact.
5Second-Pass Verification
- [ok] 目录资产面:仅 SKILL.md — skills/gsap-scrolltrigger/ 下唯一文件 SKILL.md(18,390 B);无 scripts/、references/、数据文件。
- [ok] external_deps 逐条核实调用点 — registerPlugin(ScrollTrigger) 代码块、三条 gsap.com URL(文档链接、batch()、scrollerProxy())均在文件内逐字命中,无自造端点。
- [ok] 「ease: none 是硬约束」是否有原文支撑 — 原文两处强调:配方第 2 步「Use **ease: "none"** on that tween」与 Caveats「The container animation must use **ease: "none"**.」,并解释原因是 1:1 映射会被缓动破坏。
- [ok] batch 回调签名描述(两参数)是否属实 — 原文明确「Batched callbacks receive **two** parameters (unlike normal ScrollTrigger callbacks, which receive the instance)」,与 GSAP 官方 batch 行为一致。
- [ok] scrollerProxy getter/setter 双态语义描述 — 原文「called **with** an argument, it is a setter; called **with no** argument → getter」并给出 arguments.length 判定的示例代码,符合官方 API。
- [ok] 安全反例搜索(隐藏脚本/网络/凭证) — 对该文件 token 扫描:curl/wget/fetch(/XMLHttpRequest/exec(/child_process/process.env/.env/API_KEY/secret 全零命中;URL 仅 3 条 gsap.com。
- [ok] 与 gsap-performance / gsap-react 的表述是否冲突 — 三者对 scrub、refresh、React 清理的说法一致(performance 提出去抖 refresh、react 提供 useGSAP 自动清理),无自相矛盾。
- [ok] 元数据与 pin — frontmatter license MIT;本地 HEAD = aed9cfd3277740755f6bfc1155c7aa645403b760;GitHub API stars 15326 / pushed_at 2026-07-29T17:36:08Z(晚于 pin,结论不跨版本)。
6Verdict & Scenarios
d77050ca6e9970e0…