1.2 KiB
1.2 KiB
name, description, disable-model-invocation
| name | description | disable-model-invocation |
|---|---|---|
| add-animation | Add animation to a component with proper setup and cleanup | true |
Add Animation
Add animation to: $ARGUMENTS
Process
-
Choose animation library
- GSAP: Complex timelines, ScrollTrigger, text splitting
- Framer Motion: Simple component animations, gestures, layout
- CSS: Basic transitions, hover states
-
For GSAP animations
- Register plugins at file level
- Use
gsap.context()for cleanup - Return
() => ctx.revert()from useEffect - Use refs for target elements
-
For Framer Motion
- Wrap conditionally rendered elements in
AnimatePresence - Add
keyprop for AnimatePresence children - Use
initial,animate,exitprops
- Wrap conditionally rendered elements in
-
For scroll-triggered animations
- Set appropriate
startandendpoints - Use
toggleActionsfor replay behavior - Consider mobile: disable or simplify
- Set appropriate
-
Performance considerations
- Use transform properties (x, y, scale, rotation)
- Add
force3D: truefor GPU acceleration - Check if animation should be disabled on mobile
Output
Show the implemented animation code with proper cleanup.