GSAP : animations web avancées

VérifiéSûr

Guide pratique pour créer des animations JavaScript avec GSAP : tweens, timelines, ScrollTrigger, SVG et React. Inclut des exemples de code et des bonnes pratiques.

Spar Skills Guide Bot
DeveloppementIntermédiaire
17/11/2026
Claude CodeCursorWindsurfCopilotCodex
#gsap#animation#scrolltrigger#timeline#svg

Recommandé pour

Synthèse automatique

Guide pratique pour GSAP couvrant les tweens, les timelines séquencées, les animations liées au défilement via ScrollTrigger, l'intégration React avec useGSAP et le découpage de texte.

Points forts

  • Progression par étapes claires, du tween simple jusqu'aux timelines et à ScrollTrigger
  • Exemples de code complets et directement réutilisables, y compris l'intégration React avec useGSAP et la portée par ref
  • Couvre les plugins avancés (SplitText, MorphSVG, DrawSVG, Flip) et précise leur gratuité depuis le rachat par Webflow
  • Mentionne les bonnes pratiques de responsive et de réduction de mouvement via gsap.matchMedia()

Limites

  • Suppose un projet JavaScript/React déjà configuré avec npm ; aucune aide sur l'installation initiale ou le build
  • Le nettoyage des animations et le comportement côté SSR/hydratation ne sont pas détaillés hors du cas React
  • La section sur le découpage de texte et matchMedia est incomplète, coupée en pleine phrase
Quand l'utiliser

À utiliser pour construire des animations web élaborées : timelines séquencées, effets liés au scroll, morphing SVG ou animations de texte.

Quand l'éviter

À éviter si vous cherchez des animations CSS pures et légères sans dépendance externe, ou si le projet n'a pas encore de socle JavaScript outillé.

Analyse de sécurité

Sûr
Score qualité86/100

The content is purely reference documentation for a well-known animation library. It contains no credential handling, network calls beyond an npm install example, no eval/base64 payloads, and no attempts to override agent instructions or safety rules. All code samples are standard GSAP usage patterns.

Points d'attention
  • •The SKILL.md includes shell snippets (`npm install gsap @gsap/react`), but these are ordinary package-install examples rather than executed actions; no exfiltration, destructive commands, or obfuscation is present.
  • •Minor: `no declared_allowed_tools` yet the document shows bash commands — worth noting only if the platform enforces tool declarations strictly.
Comment cette analyse est faite

Exemples

Hero entrance timeline
Build a GSAP timeline that animates my hero section on page load: logo scales in, nav links fade with a stagger, then the headline slides in and the CTA pops in at the same time as the headline.
Scroll-pinned horizontal section
Use GSAP ScrollTrigger to pin a horizontal gallery section and scrub its horizontal scroll based on the section width, with smooth scrubbing.
React scroll reveal
Add scroll-triggered reveal animations to my React card grid using useGSAP with a container ref, staggering the cards when the grid hits 80% of the viewport.

name: gsap description: >- GSAP is a JavaScript animation library for tweens, timelines, scroll-driven animation (ScrollTrigger), SVG morphing and text splitting. Use it when building complex timelines, scroll-linked animations, SVG morphing, text animations, or high-performance web animations beyond CSS capabilities. license: Apache-2.0 compatibility: 'Any JavaScript, React, Vue' metadata: author: terminal-skills repository: https://github.com/greensock/GSAP version: 1.1.0 category: development tags: "gsap, animation, scrolltrigger, timeline, svg"

GSAP

Overview

GSAP (GreenSock Animation Platform) is the most powerful web animation library. Handles complex timelines, scroll-driven animations, SVG morphing, text effects, and physics-based motion. Since Webflow's support, GSAP and all its plugins (ScrollTrigger, SplitText, MorphSVG, DrawSVG, Flip and others) are free for everyone, including commercial use, under the Standard "no charge" license (https://gsap.com/standard-license). Checked against gsap 3.15.0 and @gsap/react 2.1.2 on npm (2026-10-24).

Instructions

npm install gsap @gsap/react   # plugins ship inside the gsap package: import from 'gsap/ScrollTrigger', 'gsap/SplitText'

Step 1: Basic Animations

import gsap from 'gsap'

// Animate to
gsap.to('.hero-title', { opacity: 1, y: 0, duration: 1, ease: 'power3.out' })

// Animate from
gsap.from('.card', { opacity: 0, y: 50, duration: 0.8, stagger: 0.15 })

// Set immediately
gsap.set('.hidden-element', { opacity: 0, y: 20 })

Step 2: Timelines

// Sequenced animations — play in order
const tl = gsap.timeline({ defaults: { duration: 0.6, ease: 'power2.out' } })

tl.from('.logo', { scale: 0, rotation: -180 })
  .from('.nav-link', { opacity: 0, y: -20, stagger: 0.1 }, '-=0.3')  // overlap by 0.3s
  .from('.hero-text', { opacity: 0, x: -50 })
  .from('.cta-button', { opacity: 0, scale: 0.8 }, '<')               // start at same time as previous

// Control
tl.play()
tl.reverse()
tl.pause()
tl.seek(1.5)  // jump to 1.5 seconds

Step 3: ScrollTrigger

import { ScrollTrigger } from 'gsap/ScrollTrigger'
gsap.registerPlugin(ScrollTrigger)

// Animate when scrolling into view
gsap.from('.feature-section', {
  scrollTrigger: {
    trigger: '.feature-section',
    start: 'top 80%',        // trigger when top of element hits 80% of viewport
    end: 'bottom 20%',
    toggleActions: 'play none none reverse',  // onEnter, onLeave, onEnterBack, onLeaveBack
  },
  opacity: 0,
  y: 100,
  duration: 1,
})

// Pin section during scroll
gsap.to('.horizontal-section', {
  x: () => -(document.querySelector('.horizontal-section').scrollWidth - window.innerWidth),
  scrollTrigger: {
    trigger: '.horizontal-wrapper',
    pin: true,
    scrub: 1,                // smooth scrubbing (1 second lag)
    end: () => '+=' + document.querySelector('.horizontal-section').scrollWidth,
  },
})

Step 4: React Integration

import { useRef } from 'react'
import { useGSAP } from '@gsap/react'
import gsap from 'gsap'
import { ScrollTrigger } from 'gsap/ScrollTrigger'

gsap.registerPlugin(useGSAP, ScrollTrigger)

function AnimatedSection() {
  const container = useRef(null)

  useGSAP(() => {
    gsap.from('.card', {
      opacity: 0, y: 40, stagger: 0.1, duration: 0.6,
      scrollTrigger: { trigger: container.current, start: 'top 80%' },
    })
  }, { scope: container })

  return (
    <div ref={container}>
      <div className="card">Card 1</div>
      <div className="card">Card 2</div>
      <div className="card">Card 3</div>
    </div>
  )
}

Step 5: Split text, responsive and reduced-motion

SplitText (now free) splits text into chars, words and lines. Create it with SplitText.create, which can re-split on resize via autoSplit and call your animation from onSplit. gsap.matchMedia() runs setup only when a media query matches and reverts it afterwards, which is the clean way to honor prefers-reduced-motion.

import gsap from 'gsap'
import { SplitText } from 'gsap/SplitText'
gsap.registerPlugin(SplitText)

const mm = gsap.matchMedia()

mm.add('(prefers-reduced-motion: no-preference)', () => {
  SplitText.create('.hero-title', {
    type: 'words,lines',
    mask: 'lines',              // wrap lines for a reveal effect
    autoSplit: true,            // re-split when fonts load or width changes
    onSplit(self) {
      return gsap.from(self.lines, { yPercent: 100, stagger: 0.08, duration: 0.8, ease: 'power3.out' })
    },
  })
})

Examples

Example 1: Hero entrance with a timeline

User request: "Make the logo, nav links and CTA animate in one after another when the landing page loads."

Use the Step 2 timeline: gsap.timeline({ defaults: { duration: 0.6, ease: 'power2.out' } }), .from('.logo', ...), .from('.nav-link', ..., '-=0.3') and .from('.cta-button', ..., '<'). Each step starts when the previous one ends, minus the -=0.3 overlap, and '<' starts the CTA together with the previous step. Call tl.restart() to replay.

Example 2: Fade-in sections in a React app

User request: "In my Next.js page, cards should fade up when they scroll into view."

Add 'use client' to the component, register the plugins once (gsap.registerPlugin(useGSAP, ScrollTrigger), as in Step 4), use Step 4's useGSAP with scope: container. Opening the page shows the cards hidden until the section reaches 80% of the viewport, and unmounting reverts the animation.

Guidelines

  • GSAP and every plugin are free, including commercial use; the earlier "Club" paid tiers no longer apply. Read the Standard license for its terms.
  • Register each plugin once with gsap.registerPlugin(...) before using it; with useGSAP register useGSAP too.
  • Respect reduced motion: wrap animations in gsap.matchMedia() as in Step 5.
  • Prefer animating x, y, scale, rotation and opacity (transforms) over layout properties like width or top.
  • In React, create animations inside useGSAP and use contextSafe for event handlers so cleanup works.
  • Use useGSAP hook in React — it handles cleanup automatically on unmount.
  • ScrollTrigger with scrub creates scroll-linked animations (parallax, progress).
  • stagger animates multiple elements sequentially — cleaner than manual delays.
  • Use CSS transitions for simple hover states; reach for GSAP when you need sequencing, scroll linking, or runtime control.

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/gsap-advanced-web-animation-mwirmdwo/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/gsap-advanced-web-animation-mwirmdwo' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/gsap-advanced-web-animation-mwirmdwo/download' --output '.skill-downloads/gsap-advanced-web-animation-mwirmdwo/SKILL.md.part' && mv '.skill-downloads/gsap-advanced-web-animation-mwirmdwo/SKILL.md.part' '.skill-downloads/gsap-advanced-web-animation-mwirmdwo/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Environnement déclaré par l’auteur : Any JavaScript, React, Vue

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/gsap-advanced-web-animation-mwirmdwo/SKILL.md' && test -s '.skill-downloads/gsap-advanced-web-animation-mwirmdwo/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/gsap' && cp -R '.skill-downloads/gsap-advanced-web-animation-mwirmdwo' '.claude/skills/gsap'

Cursor
test -f '.skill-downloads/gsap-advanced-web-animation-mwirmdwo/SKILL.md' && test -s '.skill-downloads/gsap-advanced-web-animation-mwirmdwo/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/gsap' && cp -R '.skill-downloads/gsap-advanced-web-animation-mwirmdwo' '.cursor/skills/gsap'

Codex
test -f '.skill-downloads/gsap-advanced-web-animation-mwirmdwo/SKILL.md' && test -s '.skill-downloads/gsap-advanced-web-animation-mwirmdwo/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/gsap' && cp -R '.skill-downloads/gsap-advanced-web-animation-mwirmdwo' '.agents/skills/gsap'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/gsap-advanced-web-animation-mwirmdwo'

openskills read 'gsap-advanced-web-animation-mwirmdwo'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/gsap-advanced-web-animation-mwirmdwo/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires