/advanced-motion-easing
When to Use
- Implementing spring-based UI transitions (not CSS ease-in-out)
- Building drag-and-drop with inertia
- Scroll-driven animations that feel native
- Choreographing staggered list entrances
- Integrating Lottie / Rive animations with code control
Do NOT use for
- Static pages with no interaction
- Transitions < 150ms (imperceptible — skip animation entirely)
Spring Config Reference (framer/motion + react-spring)
// Named presets — use these before custom tuning
const springs = {
snappy: { stiffness: 400, damping: 30, mass: 1 }, // UI micro
default: { stiffness: 260, damping: 25, mass: 1 }, // standard nav
gentle: { stiffness: 120, damping: 20, mass: 1 }, // modals, panels
wobbly: { stiffness: 180, damping: 12, mass: 1 }, // playful UIs
slow: { stiffness: 60, damping: 15, mass: 1 }, // hero reveals
}
// framer-motion usage
<motion.div animate={{ y: 0 }} transition={springs.snappy} />
// react-spring usage
const { y } = useSpring({ y: 0, config: springs.gentle })
Custom Easing Curves (css-spring-easing + GSAP)
// css-spring-easing — generates linear() from spring params
import { createEasing } from 'css-spring-easing'
const [easing, duration] = createEasing({ stiffness: 260, damping: 25 })
// → "linear(0, 0.012, 0.044...)" — native CSS, no JS runtime
element.animate({ transform: ['translateY(20px)', 'translateY(0)'] }, {
duration,
easing,
fill: 'both',
})
GPU Compositing Rules (framer/motion + GSAP guidelines)
✅ Animate: transform (translate, scale, rotate), opacity
✅ Use will-change: transform sparingly — only during animation
✅ Use translateZ(0) or translate3d to force GPU layer
❌ Never animate: width, height, top, left, margin, padding
→ triggers layout reflow on every frame
❌ Never animate: background-color, box-shadow
→ triggers paint; use opacity + pseudo-element trick instead
// Correct shadow animation
.card::after {
opacity: 0;
box-shadow: 0 8px 24px rgba(0,0,0,.2);
transition: opacity 200ms;
}
.card:hover::after { opacity: 1; }
Scroll-Driven Animations (CSS native)
/* CSS Scroll-driven (Chrome 115+) — zero JS */
@keyframes reveal {
from { opacity: 0; translate: 0 40px; }
to { opacity: 1; translate: 0 0; }
}
.card {
animation: reveal linear both;
animation-timeline: view();
animation-range: entry 0% entry 40%;
}
/* Sticky progress bar */
#progress {
position: fixed;
transform-origin: left;
animation: grow linear;
animation-timeline: scroll(root block);
}
@keyframes grow { to { transform: scaleX(1); } }
Stagger Choreography (anime.js)
import anime from 'animejs'
// Max stagger total = 400ms (beyond that feels broken)
anime({
targets: '.list-item',
opacity: [0, 1],
translateY: [16, 0],
easing: 'spring(1, 80, 10, 0)',
delay: anime.stagger(50, { start: 0 }), // 50ms × n items
duration: 350,
})
// 8 items × 50ms = 400ms — at limit; more items → reduce delay
// Rule: (n_items × stagger_ms) + duration ≤ 800ms total
Lottie Integration (lottie-web)
import lottie from 'lottie-web'
const anim = lottie.loadAnimation({
container: document.getElementById('lottie'),
renderer: 'svg', // SVG for quality; canvas for 60fps perf
loop: false,
autoplay: false,
path: '/animations/success.json',
})
// Control from code (theatre.js pattern)
anim.addEventListener('DOMLoaded', () => {
anim.goToAndStop(0, true) // start at frame 0
})
function playOnHover() { anim.play() }
function reset() { anim.goToAndStop(0, true) }
Reduced-Motion (mandatory — framer/motion hook)
import { useReducedMotion } from 'framer-motion'
function AnimatedCard() {
const reduceMotion = useReducedMotion()
return (
<motion.div
initial={{ opacity: reduceMotion ? 1 : 0, y: reduceMotion ? 0 : 20 }}
animate={{ opacity: 1, y: 0 }}
transition={reduceMotion ? { duration: 0 } : springs.default}
/>
)
}
// CSS fallback (always include both)
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
transition-duration: 0.01ms !important;
}
}
Anti-Fake-Pass Checklist
❌ Animating width/height/top/left (layout thrash)
❌ Stagger total > 800ms (items beyond 8 at 50ms stagger)
❌ will-change: transform left on permanently (memory leak)
❌ No prefers-reduced-motion guard
❌ Lottie using canvas renderer for < 60fps SVG-quality use case
❌ CSS transition on box-shadow (use opacity + ::after trick)
❌ Spring damping < 10 (infinite oscillation)
1---2name: advanced-motion-easing3description: "Production-grade motion engineering from 20 repos. Spring physics, custom easing curves, GPU compositing rules, scroll-driven animations, micro-interactions, Lottie integration, reduced-motion, and stagger choreography. Sources: framer/motion, pmndrs/react-spring, popmotion, animejs, GSAP, auto-animate, @formkit/drag-and-drop, lottie-web, use-gesture, motion-canvas, react-transition-group, swiper, embla-carousel, scrollreveal, lax.js, use-spring, react-use-gesture, theatre.js, rive-app/rive-wasm, css-spring-easing."4origin: yana-ai — synthesized from framer/motion, pmndrs/react-spring, popmotion/popmotion, juliangarnier/anime, greensock/gsap, formkit/auto-animate, formkit/drag-and-drop, airbnb/lottie-web, pmndrs/use-gesture, motion-canvas/motion-canvas, reactjs/react-transition-group, nolimits4web/swiper, davidcetinkaya/embla-carousel, jlmakes/scrollreveal, alexfoxy/lax.js, nicowillis/use-spring, pmndrs/react-use-gesture, ArthurHub/theatre, rive-app/rive-wasm, nicowillis/css-spring-easing5license: Apache-2.06version: 1.0.07compatibility: yana-ai >= 1.3.378metadata:9 source: https://skillmd.com/skills/yanacuti1121/advanced-motion-easing10---1112# /advanced-motion-easing1314## When to Use1516- Implementing spring-based UI transitions (not CSS ease-in-out)17- Building drag-and-drop with inertia18- Scroll-driven animations that feel native19- Choreographing staggered list entrances20- Integrating Lottie / Rive animations with code control2122## Do NOT use for2324- Static pages with no interaction25- Transitions < 150ms (imperceptible — skip animation entirely)2627---2829## Spring Config Reference (framer/motion + react-spring)3031```javascript32// Named presets — use these before custom tuning33const springs = {34 snappy: { stiffness: 400, damping: 30, mass: 1 }, // UI micro35 default: { stiffness: 260, damping: 25, mass: 1 }, // standard nav36 gentle: { stiffness: 120, damping: 20, mass: 1 }, // modals, panels37 wobbly: { stiffness: 180, damping: 12, mass: 1 }, // playful UIs38 slow: { stiffness: 60, damping: 15, mass: 1 }, // hero reveals39}4041// framer-motion usage42<motion.div animate={{ y: 0 }} transition={springs.snappy} />4344// react-spring usage45const { y } = useSpring({ y: 0, config: springs.gentle })46```4748---4950## Custom Easing Curves (css-spring-easing + GSAP)5152```javascript53// css-spring-easing — generates linear() from spring params54import { createEasing } from 'css-spring-easing'5556const [easing, duration] = createEasing({ stiffness: 260, damping: 25 })57// → "linear(0, 0.012, 0.044...)" — native CSS, no JS runtime5859element.animate({ transform: ['translateY(20px)', 'translateY(0)'] }, {60 duration,61 easing,62 fill: 'both',63})64```6566---6768## GPU Compositing Rules (framer/motion + GSAP guidelines)6970```71✅ Animate: transform (translate, scale, rotate), opacity72✅ Use will-change: transform sparingly — only during animation73✅ Use translateZ(0) or translate3d to force GPU layer7475❌ Never animate: width, height, top, left, margin, padding76 → triggers layout reflow on every frame7778❌ Never animate: background-color, box-shadow79 → triggers paint; use opacity + pseudo-element trick instead8081// Correct shadow animation82.card::after {83 opacity: 0;84 box-shadow: 0 8px 24px rgba(0,0,0,.2);85 transition: opacity 200ms;86}87.card:hover::after { opacity: 1; }88```8990---9192## Scroll-Driven Animations (CSS native)9394```css95/* CSS Scroll-driven (Chrome 115+) — zero JS */96@keyframes reveal {97 from { opacity: 0; translate: 0 40px; }98 to { opacity: 1; translate: 0 0; }99}100101.card {102 animation: reveal linear both;103 animation-timeline: view();104 animation-range: entry 0% entry 40%;105}106107/* Sticky progress bar */108#progress {109 position: fixed;110 transform-origin: left;111 animation: grow linear;112 animation-timeline: scroll(root block);113}114@keyframes grow { to { transform: scaleX(1); } }115```116117---118119## Stagger Choreography (anime.js)120121```javascript122import anime from 'animejs'123124// Max stagger total = 400ms (beyond that feels broken)125anime({126 targets: '.list-item',127 opacity: [0, 1],128 translateY: [16, 0],129 easing: 'spring(1, 80, 10, 0)',130 delay: anime.stagger(50, { start: 0 }), // 50ms × n items131 duration: 350,132})133// 8 items × 50ms = 400ms — at limit; more items → reduce delay134135// Rule: (n_items × stagger_ms) + duration ≤ 800ms total136```137138---139140## Lottie Integration (lottie-web)141142```javascript143import lottie from 'lottie-web'144145const anim = lottie.loadAnimation({146 container: document.getElementById('lottie'),147 renderer: 'svg', // SVG for quality; canvas for 60fps perf148 loop: false,149 autoplay: false,150 path: '/animations/success.json',151})152153// Control from code (theatre.js pattern)154anim.addEventListener('DOMLoaded', () => {155 anim.goToAndStop(0, true) // start at frame 0156})157158function playOnHover() { anim.play() }159function reset() { anim.goToAndStop(0, true) }160```161162---163164## Reduced-Motion (mandatory — framer/motion hook)165166```javascript167import { useReducedMotion } from 'framer-motion'168169function AnimatedCard() {170 const reduceMotion = useReducedMotion()171 return (172 <motion.div173 initial={{ opacity: reduceMotion ? 1 : 0, y: reduceMotion ? 0 : 20 }}174 animate={{ opacity: 1, y: 0 }}175 transition={reduceMotion ? { duration: 0 } : springs.default}176 />177 )178}179180// CSS fallback (always include both)181@media (prefers-reduced-motion: reduce) {182 *, *::before, *::after {183 animation-duration: 0.01ms !important;184 transition-duration: 0.01ms !important;185 }186}187```188189---190191## Anti-Fake-Pass Checklist192193```194❌ Animating width/height/top/left (layout thrash)195❌ Stagger total > 800ms (items beyond 8 at 50ms stagger)196❌ will-change: transform left on permanently (memory leak)197❌ No prefers-reduced-motion guard198❌ Lottie using canvas renderer for < 60fps SVG-quality use case199❌ CSS transition on box-shadow (use opacity + ::after trick)200❌ Spring damping < 10 (infinite oscillation)201```