2.0 KiB
2.0 KiB
paths
| paths | |||
|---|---|---|---|
|
Animation Patterns
Button Animation Types
Apply to tagAnimation or buttonAnimation props:
type ButtonAnimationType = "none" | "opacity" | "slide-up" | "blur-reveal";
none- No animationopacity- Fade inslide-up- Fade + slide from bottomblur-reveal- Fade with blur clearing
Text Animation Types
Set via defaultTextAnimation in ThemeProvider or type prop in TextAnimation:
type AnimationType = "entrance-slide" | "reveal-blur" | "background-highlight";
entrance-slide- Characters slide up from bottomreveal-blur- Text appears with blur clearingbackground-highlight- Text highlights from dim to full opacity
Animation Hooks
import { useButtonAnimation } from "@/components/hooks/useButtonAnimation";
// Animate children on scroll
const { containerRef } = useButtonAnimation({ animationType: "slide-up" });
<div ref={containerRef}>
<button>Animates on scroll</button>
</div>
CardStack Animation Types
none- No animationopacity- Fade inslide-up- Slide with staggerscale-rotate- Scale + rotate with staggerblur-reveal- Blur to clear with staggerdepth-3d- 3D perspective (grid only, desktop)
GSAP Best Practices
Plugin Registration
Register plugins at file level, not in useEffect:
import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
gsap.registerPlugin(ScrollTrigger);
Cleanup with gsap.context()
Always use gsap.context() for proper cleanup:
useEffect(() => {
const ctx = gsap.context(() => {
gsap.to(".element", { opacity: 1 });
}, containerRef);
return () => ctx.revert();
}, []);
Performance
- Use
force3D: truefor GPU acceleration - Prefer transform properties (x, y, scale, rotation)
- Consider disabling complex animations on mobile