AThevon/genjutsu / skills/_jutsu/gsap
gsap
VerifiedGSAP animation engine sub-skill - core, timeline, ScrollTrigger, plugins.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 6.1 KB |
| references/core.md | markdown | 7.5 KB |
| references/plugins.md | markdown | 9.0 KB |
| references/scrolltrigger.md | markdown | 7.8 KB |
| references/timeline.md | markdown | 5.5 KB |
references/plugins.md
View on GitHub# GSAP Plugins
## SplitText (Free since v3.13)
Splits text into `chars`, `words`, `lines` for granular animations.
### Usage
```js
import { SplitText } from "gsap/SplitText";
gsap.registerPlugin(SplitText);
const split = SplitText.create(".headline", {
type: "chars, words, lines",
mask: "lines", // masks lines (clip overflow for reveal)
linesClass: "line",
charsClass: "char",
wordsClass: "word",
});
// Animate chars
gsap.from(split.chars, {
y: 50,
opacity: 0,
stagger: 0.03,
duration: 0.6,
ease: "power3.out",
});
```
### autoSplit + onSplit (v3.13+)
Automatic re-split on resize (when lines change).
```js
SplitText.create(".text", {
type: "lines, words",
mask: "lines",
autoSplit: true, // re-split au resize
onSplit(self) {
return gsap.from(self.words, {
y: "100%",
opacity: 0,
stagger: 0.04,
duration: 0.7,
});
// Returning the tween allows autoSplit to kill/recreate it
},
});
```
### Revert
Always revert after animation to clean up the DOM.
```js
// BAD - spans remain in the DOM indefinitely
const split = SplitText.create(".text", { type: "chars" });
gsap.from(split.chars, { opacity: 0 });
// GOOD - revert when the animation is finished
const split = SplitText.create(".text", { type: "chars" });
gsap.from(split.chars, {
opacity: 0,
stagger: 0.02,
onComplete: () => split.revert(),
});
// OR use autoSplit + onSplit which handles the cycle automatically
```
## Flip
Animates layout changes (position, size) with a smooth transition. FLIP technique: First, Last, Invert, Play.
### Usage
```js
import { Flip } from "gsap/Flip";
gsap.registerPlugin(Flip);
// 1. Capture the current state
const state = Flip.getState(".items");
// 2. Modify the DOM / layout
container.appendChild(movedElement);
// or toggle a class, reorder, etc.
// 3. Animate from the old state to the new one
Flip.from(state, {
duration: 0.8,
ease: "power2.inOut",
stagger: 0.05,
absolute: true, // uses position absolute during the animation
onEnter: (elements) => gsap.fromTo(elements, { opacity: 0, scale: 0 }, { opacity: 1, scale: 1 }),
onLeave: (elements) => gsap.to(elements, { opacity: 0, scale: 0 }),
});
```
### Flip.fit()
Matches the size/position of one element to another.
```js
// Makes .box match the position/size of .target
Flip.fit(".box", ".target", {
scale: true, // uses scale instead of width/height
duration: 0.5,
});
```
### Flip pitfall
```js
// BAD - getState AFTER the DOM change = no reference
container.appendChild(element);
const state = Flip.getState(".items"); // TOO LATE
// GOOD - getState BEFORE the change
const state = Flip.getState(".items");
container.appendChild(element);
Flip.from(state, { duration: 0.6 });
```
## MorphSVG
Morphs one SVG path into another.
### Usage
```js
import { MorphSVGPlugin } from "gsap/MorphSVGPlugin";
gsap.registerPlugin(MorphSVGPlugin);
gsap.to("#circle", {
morphSVG: "#star", // target shape (selector or path data)
duration: 1.5,
ease: "power2.inOut",
});
// With path data string
gsap.to("#shape", {
morphSVG: "M10,10 C20,20 40,20 50,10",
duration: 1,
});
```
### findShapeIndex
Interactive tool to find the best starting point for the morph.
```js
// Dev only - opens an interactive tool
MorphSVGPlugin.findShapeIndex("#circle", "#star");
```
### Convert primitives to path
```js
// Converts rect, circle, ellipse, polygon, polyline, line to <path>
MorphSVGPlugin.convertToPath("circle, rect, ellipse");
```
### MorphSVG pitfall
```js
// BAD - morph between shapes with very different point counts = chaotic result
gsap.to("#simple-circle", { morphSVG: "#complex-illustration" });
// GOOD - use shapes with similar complexity, or shapeIndex to optimize
gsap.to("#simple-circle", {
morphSVG: { shape: "#complex-shape", shapeIndex: 2 }, // test with findShapeIndex
});
```
## DrawSVG
Animates an SVG stroke (drawing effect).
### Usage
```js
import { DrawSVGPlugin } from "gsap/DrawSVGPlugin";
gsap.registerPlugin(DrawSVGPlugin);
// Draws the stroke from 0% to 100%
gsap.from(".path", { drawSVG: 0, duration: 2, ease: "power2.inOut" });
// Animate a portion of the stroke
gsap.fromTo(".path",
{ drawSVG: "0% 0%" },
{ drawSVG: "0% 100%", duration: 2 }
);
// Moving portion
gsap.to(".path", { drawSVG: "50% 60%", duration: 1 });
// Timeline for "snake" effect
const tl = gsap.timeline({ repeat: -1 });
tl.fromTo(".path",
{ drawSVG: "0% 0%" },
{ drawSVG: "0% 30%", duration: 1 }
).to(".path",
{ drawSVG: "100% 100%", duration: 1 }
);
```
### DrawSVG pitfall
```js
// BAD - the element has no stroke defined in CSS/SVG
gsap.from(".path", { drawSVG: 0 }); // nothing happens
// GOOD - always define a visible stroke
// CSS: .path { stroke: #fff; stroke-width: 2; fill: none; }
gsap.from(".path", { drawSVG: 0, duration: 2 });
```
## MotionPath (Free)
Animates an element along an SVG path.
### Usage
```js
import { MotionPathPlugin } from "gsap/MotionPathPlugin";
gsap.registerPlugin(MotionPathPlugin);
gsap.to(".rocket", {
motionPath: {
path: "#flight-path", // SVG path to follow
align: "#flight-path", // aligns the element on the path
alignOrigin: [0.5, 0.5], // center of the element
autoRotate: true, // rotates in the direction of movement
autoRotate: 90, // rotation offset in degrees
start: 0, // start position (0-1)
end: 1, // end position (0-1)
},
duration: 3,
ease: "power1.inOut",
});
```
### Path with coordinates
```js
gsap.to(".ball", {
motionPath: {
path: [
{ x: 100, y: 0 },
{ x: 200, y: -100 },
{ x: 300, y: 0 },
],
curviness: 1.5, // 0 = linear, 2 = very curved
autoRotate: true,
},
duration: 2,
});
```
### MotionPath pitfall
```js
// BAD - autoRotate without alignOrigin = the element rotates around its corner
gsap.to(".el", {
motionPath: { path: "#path", autoRotate: true },
});
// GOOD - always define align + alignOrigin with autoRotate
gsap.to(".el", {
motionPath: {
path: "#path",
align: "#path",
alignOrigin: [0.5, 0.5],
autoRotate: true,
},
});
```
## Observer (Free)
Detects user gestures (scroll, touch, pointer) without ScrollTrigger. Ideal for custom interactions (swipe, drag-to-reveal).
### Usage
```js
import { Observer } from "gsap/Observer";
gsap.registerPlugin(Observer);
Observer.create({
type: "wheel, touch, pointer", // event types to listen to
target: window, // target element
onUp: () => goToSection(-1), // scroll/swipe up
onDown: () => goToSection(1), // scroll/swipe down
tolerance: 50, // minimum pixels before triggering
preventDefault: true, // prevents native scroll
wheelSpeed: -1, // inverts wheel direction
onPress: (self) => {}, // pointer down
onRelease: (self) => {}, // pointer up
onDrag: (self) => {}, // during drag
onChange: (self) => {
self.deltaX; // X displacement
self.deltaY; // Y displacement
self.velocityX; // X velocity
self.velocityY; // Y velocity
},
});
```
### Full-page section transitions
```js
let currentIndex = 0;
const sections = gsap.utils.toArray(".section");
let animating = false;
function goToSection(direction) {
if (animating) return;
const nextIndex = gsap.utils.clamp(0, sections.length - 1, currentIndex + direction);
if (nextIndex === currentIndex) return;
animating = true;
gsap.to(sections[currentIndex], { yPercent: -100 * direction, duration: 0.8 });
gsap.fromTo(sections[nextIndex],
{ yPercent: 100 * direction },
{ yPercent: 0, duration: 0.8, onComplete: () => (animating = false) }
);
currentIndex = nextIndex;
}
Observer.create({
type: "wheel, touch",
onUp: () => goToSection(-1),
onDown: () => goToSection(1),
tolerance: 80,
preventDefault: true,
});
```
### Observer pitfall
```js
// BAD - no debounce/lock = animations stacking up
Observer.create({
onDown: () => gsap.to(".box", { y: "+=100" }), // each scroll adds 100px
// GOOD - lock during animation
let animating = false;
Observer.create({
onDown: () => {
if (animating) return;
animating = true;
gsap.to(".box", { y: "+=100", onComplete: () => (animating = false) });
},
});
```
## Recap : plugins
Since GSAP 3.13 (2025, post-Webflow acquisition) the entire library - including every former Club/bonus plugin (MorphSVG, DrawSVG, ScrollSmoother, SplitText, MotionPathHelper...) - is 100% free for all uses. There is no more Club paywall.
| Plugin | Usage principal |
| -------------- | ---------------------------------- |
| ScrollTrigger | Scroll-driven animations |
| Observer | Gesture detection |
| MotionPath | Path following |
| Flip | Layout transitions |
| SplitText | Text splitting |
| MorphSVG | SVG shape morphing |
| DrawSVG | SVG stroke animation |
| CustomEase | Custom easing curves |
| ScrollSmoother | Smooth scrolling wrapper |
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |