Communitygithub.com

whoamnesia/gsap

astudio 的 GSAP 動畫:時間軸、ScrollTrigger 滾動敘事(固定、擦洗、水平畫廊、視差)、SplitText 標題揭示、Flip 佈局轉換、MorphSVG/DrawSVG/MotionPath、Draggable/Inertia/Observer、CustomEase、quickTo 游標跟隨器、Lenis 平滑滾動、頁面轉換(Barba、View Transitions)以及獲獎級別的落地頁動畫,支援 vanilla JS、React (useGSAP)、Next.js、Vue、Nuxt、Svelte 和 Astro——包含清理、響應式和減少動畫處理(透過 gsap.matchMedia)。用於「GSAP」、「ScrollTrigger」、「滾動動畫」、「固定區塊」、「水平滾動」、「文字揭示」、「如同 Awwwards 等級」、「滾動動畫」、「視差」。所有 GSAP 外掛都免費(GSAP 3.13+)。

gsap 是什麼?

這個技能定義了一個專業的 GSAP 開發工作流程,專注於建立 Awwwards 等級的滾動敘事和時間軸動畫,適用於行銷登陸頁、品牌網站和作品集。它涵蓋了從專案初始化、元素標記到效能檢查的完整流程。技能要求使用特定的腳本工具(`motion.cjs`)來檢查動畫覆蓋率(目標 >90%,包含文字)和品質(無硬停止或空開場)。它強調使用 `gsap.matchMedia()` 處理響應式和減少動畫偏好,以及正確的框架整合(React 的 `useGSAP` 等)。核心準則包括:使用時間軸而非延遲鏈、在生產環境中禁用 `markers`、使用 `transform` 和 `autoAlpha` 進行動畫而非 `top/left`,以及使用 Lenis 或 ScrollSmoother 實現平滑滾動。該技能支援所有 GSAP 外掛(SplitText、MorphSVG、DrawSVG 等),並強調它們都包含在公共套件中,無需設定私有的 GreenSock 註冊表。

相容平台~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/whoamnesia/motion-3d/tree/HEAD/skills/gsap

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

astudio · GSAP

角色:astudio.one 的高級創意開發人員(15 年以上經驗)—— 打造 Awwwards 等級的滾動故事和時間軸,始終保持 60fps 且不會造成讀者卡住。標準:<root>/reference/studio-bar.md;<root> = 此技能基礎目錄的上兩層,或存放 scripts/motion.cjs 的資料夾。

設定事實(切勿搞錯)

  • npm i gsap - 每個外掛都是免費的,並且包含在公開套件中(SplitText、MorphSVG、DrawSVG、ScrollSmoother、Inertia……)。切勿產生包含 GreenSock token 的 .npmrc,也不要引導使用者前往舊的 Club 註冊表。
  • 從 gsap/<Plugin> 匯入,並在模組頂層(而非重新渲染的元件內部)呼叫一次 gsap.registerPlugin(...)。React:npm i @gsap/react,gsap.registerPlugin(useGSAP)。
  • 靜態頁面的 CDN:https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js(+ /dist/ScrollTrigger.min.js、SplitText.min.js、DrawSVGPlugin.min.js、MotionPathPlugin.min.js);Lenis https://unpkg.com/[email protected]/dist/lenis.min.js。

為整個網站製作動畫(行銷、落地頁、品牌、作品集)—— 全面編排

請先閱讀 <root>/reference/site-motion.md。使用者期望每個元素——包括文字——都能流暢且和諧地表現;一個動態的主題區搭配靜態區塊是不合格的。

  1. 從 templates/site-motion.js + templates/site-motion.css 開始(將它們複製到專案中):包含依據內容類型揭示的語法、簡介時間軸、Lenis、標籤滾動按鈕、磁吸效果、計數器、跑馬燈和地圖/路線用的 SiteMotion.map()。根據品牌調整 token(SiteMotion.init({ tokens: {...} })),絕不能低於流暢度底線。
  2. 為每個可見元素標記 data-reveal="<type>"(標題、段落、標籤、按鈕、連結、圖片、卡片、行、圖示、數字、分隔線、徽章、頁首、頁尾);主題容器需加上 data-hero;地圖需加上 data-map 及地圖屬性。加入 <head> 中的內聯腳本(sm-js + 容錯機制)。
  3. 主題照片為 hero-image(第 0 幀可見,確保 LCP 安全)。然後使用相同的 token 在上面設計標誌性效果(一個固定場景、地圖旅程、3D 揭示)。
  4. 檢查:執行 node <root>/scripts/motion.cjs coverage index.html(無 FAIL,>= 90% 元素有動畫,包含文字,LCP 延遲 < 300ms)· 執行 motion.cjs check index.html --duration 2.5(無 hard-stop,無 empty-opening)· 主題區和滾動區塊的片段 · 執行 motion_lint.py . --mode marketing。

工作流程(任何 GSAP 專案)

  1. 決定關鍵時刻(<root>/reference/direction.md):哪一個場景是標誌性的(主題區介紹、固定的故事、水平畫廊、文字揭示),以及在展示型網站上,圍繞它的全面編排(<root>/reference/site-motion.md)。尋找模式:search.py "<idea>" -d gsap / -d ui / -d transition。
  2. 建立時間軸,而非延遲鏈(references/core.md):在時間軸上設定預設值,使用 position 參數實現重疊("<"、"-=0.3"、標籤),根據角色使用不同的 ease(到達用 expo.out,移動用 power2.inOut,擦洗用 none)。
  3. 滾動(references/scrolltrigger.md):僅在時間軸或頂級 tween 上使用 ScrollTrigger;使用 scrub 或 toggleActions;固定區域不超過 2-3 個螢幕高度且進度可見;使用 containerAnimation 時設 ease: "none";從上到下建立觸發器(或使用 refreshPriority);在圖片/字型/動態內容載入後呼叫 ScrollTrigger.refresh()。
  4. 根據需要使用外掛(references/plugins.md):SplitText(遮罩中的行/詞,用於響應式的 autoSplit + onSplit,清理時復原)、Flip、MorphSVG/DrawSVG、MotionPath、Draggable+Inertia、Observer、ScrollSmoother 或 Lenis、CustomEase。SplitText:標題按詞/字元,內文按行(mask: "lines"),揭示結束時復原。
  5. 框架整合和清理(references/frameworks.md):在 React 中使用 useGSAP({ scope }) 搭配 contextSafe 處理事件處理器;其他地方使用 gsap.context() + revert();在卸載和路由變更時 kill/revert。
  6. 響應式和無障礙處理集中在一個地方:使用 gsap.matchMedia() 搭配條件 isDesktop、reduceMotion(<root>/reference/accessibility.md 等級 - 減少動畫下無固定/視差/擦洗移動;保留淡入淡出效果)。即使沒有 JS,內容也應可見:透過 matchMedia 內部的 gsap.set 設定隱藏的起始狀態,或使用從-tween 的 autoAlpha。
  7. 檢查:執行 node <root>/scripts/motion.cjs strip page.html --duration 3 --frames 12 檢查載入時間軸;對於滾動場景,暴露一個測試鉤子,將 t 映射到滾動位置或進度(references/scrolltrigger.md §6)並進行片段測試;執行 motion_lint.py src --mode marketing。

規則

  • 使用轉換屬性別名(x、y、xPercent、scale、rotation)和 autoAlpha——切勿使用 top/left/width/height 來進行移動動畫。當動畫結束後 CSS 應接管時,使用 clearProps。
  • 對同一目標的同一屬性使用多個 from()/fromTo():後面的 those 需設定 immediateRender: false。
  • 對於可能被重新觸發的 tween,設定 overwrite: "auto";對於游標跟隨器/磁吸按鈕,使用 gsap.quickTo()。
  • 生產環境中不使用 markers: true;不使用 scroll 事件監聽器來驅動動畫。
  • 僅固定必要的元素;scrub: 0.8-1.2 以獲得流暢的重量(對於可見的移動,絕不使用原始的 scrub: true);當固定區域會跳動時設定 anticipatePin: 1;對於依賴視口大小的函數式數值,使用 invalidateOnRefresh。
  • 展示型網站的流暢度底線:揭示動畫持續時間 >= 0.9s(使用 expo.out/power4.out),重疊的 staggers,帶有內部縮放的圖片擦除;沒有任何動畫會突然停止在最高速度(motion.cjs check -> hard-stop)。
  • SVG 變換原點:僅使用 GSAP 的 transformOrigin/svgOrigin——絕不額外使用 CSS 的 transform-box(會造成雙倍偏移)。
  • 平滑滾動(Lenis/ScrollSmoother)僅在桌面端精細指針設備上啟用;在減少動畫和觸控設備上關閉;將 Lenis 連接到 ticker(lenis.on('scroll', ScrollTrigger.update); gsap.ticker.add(t => lenis.raf(t * 1000)); gsap.ticker.lagSmoothing(0))。
  • 影片時間軸(astudio-motion:motion-video):一個暫停的主時間軸,window.__seek = t => tl.seek(t),無 repeat: -1,無未使用種子的 Math.random()。

Individual skills in this repo

This repo contains 3 individual skills — each has its own dedicated page.

whoamnesia/lottie-rive

Lottie and Rive by astudio: integrating, controlling and optimising designer-made animation in products - dotLottie/Lottie playback, segments, scroll-driven and interactive Lottie, runtime theming, size optimisation; Rive state machines (inputs, transitions, listeners), data binding with view models, events, runtimes for web, React, React Native, iOS, Android, Flutter; choosing Lottie vs Rive vs code; preparing files for handoff (After Effects + Bodymovin, Figma Motion, Lottie Creator, Cavalry exports). Use for "Lottie", ".lottie", "Bodymovin", "Rive", ".riv", "state machine animation", "interactive illustration", "анимированная иконка из After Effects", "встроить анимацию от дизайнера".

whoamnesia/motion-review

Motion review and audit by astudio: reviews animation code and rendered motion against a strict craft bar, audits a whole codebase's motion, diagnoses jank and performance, finds where motion is missing (opportunities) and removes motion that should not exist - for websites, product UI, GSAP/Motion/CSS, Lottie/Rive, three.js and rendered videos. Use for "review my animations", "why is this janky", "this feels cheap/slow/AI-made", "audit the motion", "where should we add animation", "remove unnecessary animations", "проверь анимации", "почему дёргается", "аудит моушена". Default to flagging; approval is earned. Outputs a findings table and a Block/Approve verdict, with rendered strips as evidence.

whoamnesia/ui-motion

Interface animation by astudio: builds motion for UI components and flows - buttons, dropdowns, popovers, tooltips, modals, drawers, toasts, accordions, tabs, lists, skeletons, route/page transitions, shared-element morphs, drag and gestures - with CSS (@starting-style, scroll-driven animations), WAAPI, View Transitions, Motion (motion.dev / framer-motion) in React, Vue, Svelte or plain HTML; defines motion systems and tokens; implements Figma Motion designs via the Figma MCP (get_motion_context). Use for "animate this component", "add a transition", "make it feel alive/smooth/native", "page transition", "motion tokens", "микроанимации", "анимация интерфейса", "плавные переходы". Decides whether something should animate at all before writing code.

相關技能