1
---
2
name: gsap-framer-scroll-animation
3
description: >-
4
Use this skill whenever the user wants to build scroll animations, scroll effects,
5
parallax, scroll-triggered reveals, pinned sections, horizontal scroll, text animations,
6
or any motion tied to scroll position — in vanilla JS, React, or Next.js.
7
Covers GSAP ScrollTrigger (pinning, scrubbing, snapping, timelines, horizontal scroll,
8
ScrollSmoother, matchMedia) and Framer Motion / Motion v12 (useScroll, useTransform,
9
useSpring, whileInView, variants). Use this skill even if the user just says
10
"animate on scroll", "fade in as I scroll", "make it scroll like Apple",
11
"parallax effect", "sticky section", "scroll progress bar", or "entrance animation".
12
Also triggers for Copilot prompt patterns for GSAP or Framer Motion code generation.
13
Pairs with the premium-frontend-ui skill for creative philosophy and design-level polish.
14
metadata:
15
author: 'Utkarsh Patrikar'
16
author_url: 'https://github.com/utkarsh232005'
17
---
18
19
# GSAP & Framer Motion — Scroll Animations Skill
20
21
Production-grade scroll animations with GitHub Copilot prompts, ready-to-use code recipes, and deep API references.
22
23
> **Design Companion:** This skill provides the *technical implementation* for scroll-driven motion.
24
> For the *creative philosophy*, design principles, and premium aesthetics that should guide **how**
25
> and **when** to animate, always cross-reference the **premium-frontend-ui** skill.
26
> Together they form a complete approach: premium-frontend-ui decides the **what** and **why**;
27
> this skill delivers the **how**.
28
29
## Quick Library Selector
30
31
| Need | Use |
32
|---|---|
33
| Vanilla JS, Webflow, Vue | **GSAP** |
34
| Pinning, horizontal scroll, complex timelines | **GSAP** |
35
| React / Next.js, declarative style | **Framer Motion** |
36
| whileInView entrance animations | **Framer Motion** |
37
| Both in same Next.js app | See notes in references |
38
39
Read the relevant reference file for full recipes and Copilot prompts:
40
41
- **GSAP** → `references/gsap.md` — ScrollTrigger API, all recipes, React integration
42
- **Framer Motion** → `references/framer.md` — useScroll, useTransform, all recipes
43
44
## Setup (Always Do First)
45
46
### GSAP
47
```bash
48
npm install gsap
49
```
50
```js
51
import gsap from 'gsap';
52
import { ScrollTrigger } from 'gsap/ScrollTrigger';
53
gsap.registerPlugin(ScrollTrigger); // MUST call before any ScrollTrigger usage
54
```
55
56
### Framer Motion (Motion v12, 2025)
57
```bash
58
npm install motion # new package name since mid-2025
59
# or: npm install framer-motion — still works, same API
60
```
61
```js
62
import { motion, useScroll, useTransform, useSpring } from 'motion/react';
63
// legacy: import { motion } from 'framer-motion' — also valid
64
```
65
66
## Workflow
67
68
1. Interpret the user's intent to identify if GSAP or Framer Motion is the best fit.
69
2. Read the relevant reference document in `references/` for detailed APIs and patterns.
70
3. Suggest the required package installation if not already present.
71
4. Implement the scaffold for the animation structure, adhering to the requested format (React components, hook requirements, or vanilla JS).
72
5. Apply the correct tools (scrolling vs in-view elements) ensuring accessibility options are present and hooks don't cause infinite re-renders.
73
74
## The 5 Most Common Scroll Patterns
75
76
Quick reference — full recipes with Copilot prompts are in the reference files.
77
78
### 1. Fade-in on enter (GSAP)
79
```js
80
gsap.from('.card', {
81
opacity: 0, y: 50, stagger: 0.15, duration: 0.8,
82
scrollTrigger: { trigger: '.card', start: 'top 85%' }
83
});
84
```
85
86
### 2. Fade-in on enter (Framer Motion)
87
```jsx
88
<motion.div
89
initial={{ opacity: 0, y: 40 }}
90
whileInView={{ opacity: 1, y: 0 }}
91
viewport={{ once: true, margin: '-80px' }}
92
transition={{ duration: 0.6 }}
93
/>
94
```
95
96
### 3. Scrub / scroll-linked (GSAP)
97
```js
98
gsap.to('.hero-img', {
99
scale: 1.3, opacity: 0, ease: 'none',
100
scrollTrigger: { trigger: '.hero', start: 'top top', end: 'bottom top', scrub: true }
101
});
102
```
103
104
### 4. Scroll-linked (Framer Motion)
105
```jsx
106
const { scrollYProgress } = useScroll({ target: ref, offset: ['start end', 'end start'] });
107
const y = useTransform(scrollYProgress, [0, 1], [0, -100]);
108
return <motion.div style={{ y }} />;
109
```
110
111
### 5. Pinned timeline (GSAP)
112
```js
113
const tl = gsap.timeline({
114
scrollTrigger: { trigger: '.section', pin: true, scrub: 1, start: 'top top', end: '+=200%' }
115
});
116
tl.from('.title', { opacity: 0, y: 60 }).from('.img', { scale: 0.85 });
117
```
118
119
## Critical Rules (Apply Always)
120
121
- **GSAP**: always call `gsap.registerPlugin(ScrollTrigger)` before using it
122
- **GSAP scrub**: always use `ease: 'none'` — easing feels wrong when scrub is active
123
- **GSAP React**: use `useGSAP` from `@gsap/react`, never plain `useEffect` — it auto-cleans ScrollTriggers
124
- **GSAP debug**: add `markers: true` during development; remove before production
125
- **Framer**: `useTransform` output must go into `style` prop of a `motion.*` element, not a plain div
126
- **Framer Next.js**: always add `'use client'` at top of any file using motion hooks
127
- **Both**: animate only `transform` and `opacity` — avoid `width`, `height`, `box-shadow`
128
- **Accessibility**: always check `prefers-reduced-motion` — see each reference file for patterns
129
- **Premium polish**: follow the **premium-frontend-ui** skill principles for motion timing, easing curves, and restraint — animation should enhance, never overwhelm
130
131
## Copilot Prompting Tips
132
133
- Give Copilot the full selector, base image, and scroll range upfront — vague prompts produce vague code
134
- For GSAP, always specify: selector, start/end strings, whether you want scrub or toggleActions
135
- For Framer, always specify: which hook (useScroll vs whileInView), offset values, what to transform
136
- Paste the exact error message when asking `/fix` — Copilot fixes are dramatically better with real errors
137
- Use `@workspace` scope in Copilot Chat so it reads your existing component structure
138
139
## Reference Files
140
141
| File | Contents |
142
|---|---|
143
| `references/gsap.md` | Full ScrollTrigger API reference, 10 recipes, React (useGSAP), Lenis, matchMedia, accessibility |
144
| `references/framer.md` | Full useScroll / useTransform API, 8 recipes, variants, Motion v12 notes, Next.js tips |
145
146
## Related Skills
147
148
| Skill | Relationship |
149
|---|---|
150
| **premium-frontend-ui** | Creative philosophy, design principles, and aesthetic guidelines — defines *when* and *why* to animate |
151
152