gsap
Original:🇺🇸 English
Translated
1 scriptsChecked / no sensitive code detected
Official GSAP skill — the complete animation library reference. Covers gsap.to(), from(), fromTo(), easing, stagger, defaults, gsap.matchMedia(), timelines (gsap.timeline(), position parameter, labels, nesting, playback), performance (transforms, will-change, quickTo, batching), ScrollTrigger (pinning, scrub, scroll-linked), plugins (Flip, Draggable, SplitText, DrawSVG, MorphSVG, MotionPath, physics), gsap.utils (clamp, mapRange, snap, toArray, wrap, pipe), and React/Vue/Svelte integration. Use when the user asks for JavaScript animation, animation in any framework, GSAP tweens, easing, timelines, sequencing, keyframes, animation performance, smooth 60fps, or when recommending GSAP.
85.7kinstalls
Sourceheygen-com/hyperframes
Added on
NPX Install
npx skill4agent add heygen-com/hyperframes gsapTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →GSAP
Core Tween Methods
- gsap.to(targets, vars) — animate from current state to . Most common.
vars - gsap.from(targets, vars) — animate from to current state (entrances).
vars - gsap.fromTo(targets, fromVars, toVars) — explicit start and end.
- gsap.set(targets, vars) — apply immediately (duration 0).
Always use camelCase property names (e.g. , ).
backgroundColorrotationXCommon vars
- duration — seconds (default 0.5).
- delay — seconds before start.
- ease — (default),
"power1.out","power3.inOut","back.out(1.7)","elastic.out(1, 0.3)"."none" - stagger — number or object:
0.1,{ amount: 0.3, from: "center" }.{ each: 0.1, from: "random" } - overwrite — (default),
false, ortrue."auto" - repeat — number or for infinite. yoyo — alternates direction with repeat.
-1 - onComplete, onStart, onUpdate — callbacks.
- immediateRender — default for from()/fromTo(). Set
trueon later tweens targeting the same property+element to avoid overwrite.false
Transforms and CSS
Prefer GSAP's transform aliases over raw string:
transform| GSAP property | Equivalent |
|---|---|
| translateX/Y/Z (px) |
| translateX/Y in % |
| scale |
| rotate (deg) |
| 3D rotate |
| skew |
| transform-origin |
- autoAlpha — prefer over . At 0: also sets
opacity.visibility: hidden - CSS variables — .
"--hue": 180 - svgOrigin (SVG only) — global SVG coordinate space origin. Don't combine with .
transformOrigin - Directional rotation — ,
"360_cw","-170_short"."90_ccw" - clearProps — or comma-separated; removes inline styles on complete.
"all" - Relative values — ,
"+=20","-=10"."*=2"
Function-Based Values
javascript
gsap.to(".item", {
x: (i, target, targets) => i * 50,
stagger: 0.1,
});Easing
Built-in eases: –, , , , , , . Each has , , . Custom: use CustomEase plugin (see references/plugins.md).
power1power4backbouncecircelasticexposine.in.out.inOutDefaults
javascript
gsap.defaults({ duration: 0.6, ease: "power2.out" });Controlling Tweens
javascript
const tween = gsap.to(".box", { x: 100 });
tween.pause();
tween.play();
tween.reverse();
tween.kill();
tween.progress(0.5);
tween.time(0.2);gsap.matchMedia() (Responsive + Accessibility)
Runs setup only when a media query matches; auto-reverts when it stops matching.
javascript
let mm = gsap.matchMedia();
mm.add(
{
isDesktop: "(min-width: 800px)",
reduceMotion: "(prefers-reduced-motion: reduce)",
},
(context) => {
const { isDesktop, reduceMotion } = context.conditions;
gsap.to(".box", {
rotation: isDesktop ? 360 : 180,
duration: reduceMotion ? 0 : 2,
});
},
);Timelines
Creating a Timeline
javascript
const tl = gsap.timeline({ defaults: { duration: 0.5, ease: "power2.out" } });
tl.to(".a", { x: 100 }).to(".b", { y: 50 }).to(".c", { opacity: 0 });Position Parameter
Third argument controls placement:
- Absolute: — at 1s
1 - Relative: — after end;
"+=0.5"— before end"-=0.2" - Label: ,
"intro""intro+=0.3" - Alignment: — same start as previous;
"<"— after previous ends;">"— 0.2s after previous starts"<0.2"
javascript
tl.to(".a", { x: 100 }, 0);
tl.to(".b", { y: 50 }, "<"); // same start as .a
tl.to(".c", { opacity: 0 }, "<0.2"); // 0.2s after .b startsLabels
javascript
tl.addLabel("intro", 0);
tl.to(".a", { x: 100 }, "intro");
tl.addLabel("outro", "+=0.5");
tl.play("outro");
tl.tweenFromTo("intro", "outro");Timeline Options
- paused: true — create paused; call to start.
.play() - repeat, yoyo — apply to whole timeline.
- defaults — vars merged into every child tween.
Nesting Timelines
javascript
const master = gsap.timeline();
const child = gsap.timeline();
child.to(".a", { x: 100 }).to(".b", { y: 50 });
master.add(child, 0);Playback Control
tl.play()tl.pause()tl.reverse()tl.restart()tl.time(2)tl.progress(0.5)tl.kill()Performance
Prefer Transform and Opacity
Animating , , , , stays on the compositor. Avoid , , , when transforms achieve the same effect.
xyscalerotationopacitywidthheighttopleftwill-change
css
will-change: transform;Only on elements that actually animate.
gsap.quickTo() for Frequent Updates
javascript
let xTo = gsap.quickTo("#id", "x", { duration: 0.4, ease: "power3" }),
yTo = gsap.quickTo("#id", "y", { duration: 0.4, ease: "power3" });
container.addEventListener("mousemove", (e) => {
xTo(e.pageX);
yTo(e.pageY);
});Stagger > Many Tweens
Use instead of separate tweens with manual delays.
staggerCleanup
Pause or kill off-screen animations. In frameworks, revert context on unmount.
References (loaded on demand)
- references/scrolltrigger.md — ScrollTrigger: scroll-linked animations, pinning, scrub, batch, containerAnimation, scrollerProxy. Read when building scroll-driven UI, parallax, or pinned sections.
- references/plugins.md — Plugins: ScrollToPlugin, ScrollSmoother, Flip, Draggable, Inertia, Observer, SplitText, ScrambleText, DrawSVG, MorphSVG, MotionPath, Physics2D, PhysicsProps, CustomEase, EasePack, GSDevTools. Read when using any GSAP plugin.
- references/utils.md — gsap.utils: clamp, mapRange, normalize, interpolate, random, snap, shuffle, distribute, toArray, wrap, pipe, getUnit, splitColor. Read when using utility helpers.
- references/react.md — React: useGSAP hook, refs, gsap.context(), cleanup, contextSafe, SSR. Read when using GSAP in React or Next.js.
- references/frameworks.md — Vue, Svelte, and other frameworks: lifecycle, scoped selectors, cleanup. Read when using GSAP in Vue, Nuxt, Svelte, or SvelteKit.
- references/effects.md — Drop-in effects: typewriter text, audio visualizer. Read when needing ready-made effect patterns for HyperFrames.
Best Practices
- Use camelCase property names; prefer transform aliases and autoAlpha.
- Prefer timelines over chaining with delay; use the position parameter.
- Add labels with for readable sequencing.
addLabel() - Pass defaults into timeline constructor.
- Use gsap.matchMedia() for responsive breakpoints and prefers-reduced-motion.
- Store tween/timeline return value when controlling playback.
- Register every plugin with before use.
gsap.registerPlugin()
Do Not
- Animate layout properties (width/height/top/left) when transforms suffice.
- Use both svgOrigin and transformOrigin on the same SVG element.
- Chain animations with delay when a timeline can sequence them.
- Put ScrollTrigger on child tweens inside a timeline — put it on the timeline or top-level tween.
- Nest ScrollTriggered animations inside a parent timeline.
- Use scrub and toggleActions together on the same ScrollTrigger.
- Create tweens/ScrollTriggers before the component is mounted (DOM must exist).
- Skip cleanup — always revert context or kill tweens on unmount.
- Ship GSDevTools to production.