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 级别品质的开发者设计。它涵盖从基础时间线到复杂滚动叙事(ScrollTrigger)、文字分割动画(SplitText)、元素翻转(Flip)以及高级 SVG 动效(MorphSVG/DrawSVG)等所有核心能力。该技能深度整合了社区推荐的平滑滚动库 Lenis,并提供了与 React、Next.js、Vue、Svelte 等主流前端框架的无缝集成方式。其核心价值在于强迫性的代码规范:它要求开发者遵循严格的工作流,从项目初始到最终检查,确保动效在 60fps 下流畅运行,同时自动处理响应式布局、减少动效偏好和组件卸载时的清理工作。该技能附带了 `motion.cjs` 和 `motion_lint.py` 等自动化检查工具,能够量化评估页面动效覆盖率、LCP 延迟和视觉流畅度,将主观的“动效品质”转化为可验证的客观指标。

兼容平台~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):时间线上设置 defaults,使用位置参数实现重叠("<"、"-=0.3"、标签),按角色选择缓动函数(到达时用 expo.out,移动时用 power2.inOut,scrub 用 none)。
  3. 滚动(references/scrolltrigger.md):ScrollTrigger 仅用在时间线或顶级 tween 上;scrub 或 toggleActions 二选一;固定区域不超过 2-3 屏并显示可见进度;在 containerAnimation 中使用 ease: "none";从上到下创建触发器(或使用 refreshPriority);在图片/字体/动态内容加载后调用 ScrollTrigger.refresh()。
  4. 根据需要使用的插件(references/plugins.md):SplitText(在蒙版中使用 lines/words,autoSplit + onSplit 处理响应式,清理时 revert)、Flip、MorphSVG/DrawSVG、MotionPath、Draggable+Inertia、Observer、ScrollSmoother 或 Lenis、CustomEase。SplitText:标题按 words/chars 拆分,正文按 lines 拆分(mask: "lines"),揭示结束时 revert。
  5. 框架集成和清理(references/frameworks.md):在 React 中使用 useGSAP({ scope }) 结合 contextSafe 处理事件;在其他地方使用 gsap.context() + revert();在卸载和路由变化时 kill/revert。
  6. 响应式 + 无障碍统一处理:使用 gsap.matchMedia() 配合条件 isDesktop、reduceMotion(<root>/reference/accessibility.md 层级——减少动效下不包含固定/视差/scrub 移动;保留淡入淡出效果)。内容在无 JS 时可见:通过 gsap.set 在 matchMedia 内部设置隐藏起始状态,或使用 from-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():后续的 tween 设置 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.

相关技能