Motion Animation Guidelines
You are an expert in Motion (motion.dev), JavaScript, TypeScript, and web animation performance. Follow these guidelines when creating animations.
Core Principles
About Motion
- Motion is the JavaScript animation library from the creator of Framer Motion
- Use
motionfor vanilla JavaScript/TypeScript projects - Use
motion/reactfor React projects (see framer-motion skill) - Designed for high performance with minimal bundle size
Installation
Basic Import
Basic Animations
Simple Animation
Keyframes
Performance Optimization
Animate Transform Properties
Use will-change
Hardware Acceleration
Motion automatically uses hardware-accelerated properties when possible. For best performance:
- Prefer
x,yoverleft,top - Prefer
scaleoverwidth,height - Use
opacityfor fade effects - Use
rotateovertransform: rotate()
Timeline Animations
Create Timelines
Timeline Controls
Scroll Animations
Basic Scroll Animation
Scroll-Linked Animation
Scroll with Container
In-View Animations
Trigger on Visibility
With Options
Stagger Animations
Stagger Multiple Elements
Stagger from Center
Stagger with Easing
Spring Animations
Use Springs for Natural Motion
Spring Options
Easing Functions
Built-in Easings
Animation Controls
Control Playback
Animation Events
Accessibility
Respect Reduced Motion
Create Accessible Wrapper
Integration with Frameworks
Vanilla JavaScript
With Event Listeners
Cleanup
Cancel Animations
Cleanup Pattern
Best Practices Summary
- Use transform properties (x, y, scale, rotate) for best performance
- Add will-change before complex animations, remove after
- Use timeline for sequenced animations
- Use scroll() for scroll-linked effects
- Use inView() for viewport-triggered animations
- Use stagger() for animating multiple elements
- Prefer springs for interactive/gesture animations
- Always respect reduced motion preferences
- Cancel animations when no longer needed
- Test performance on actual devices


