GSAP Setup
Music Store uses GSAP (GreenSock Animation Platform) for all animations. GSAP is installed as a dependency and imported where needed.Installation
package.json
Basic Import
Animation Patterns
Using gsap.context()
All animations in Music Store usegsap.context() for proper cleanup and scoping. This is the recommended pattern:
Real Examples from Music Store
Hero Component Timeline
The Hero component uses a GSAP timeline to sequence multiple animations:Timeline benefits:
- Sequence multiple animations
- Control timing with overlap (
-=notation) - Set default easing for all animations
- Easier to maintain complex animation sequences
Navbar Animation
The navbar animates in from top or bottom based on the current route:Cart Panel Slide Animation
The shopping cart panel slides in from the right with an overlay fade:Stagger Animation
Product cards animate in with a stagger effect:Animation Properties
Common Properties
- Transform
- Opacity
- Timing
- Other
Easing Functions
Music Store primarily usespower3.out and power3.in for natural motion:
power3.out
Starts fast, ends slow. Best for entrance animations.
power3.in
Starts slow, ends fast. Best for exit animations.
Animation Timing
Timeline Positioning
Control when animations start in a timeline:Stagger
Animate multiple elements with a delay between each:Best Practices
Choose appropriate easing
- Use
power3.outfor entrance animations - Use
power3.infor exit animations - Consistent easing creates cohesive motion
Performance Tips:
x,y,scale,rotation,opacityare performant- Avoid animating
top,left,margin,padding - Use
gsap.set()for instant property changes - Batch animations when possible
Animation Checklist
Entry Animations
- Start with
opacity: 0 - Offset position (
y: 30) - Use
fromTo()method - Add slight delay
Exit Animations
- Animate to
opacity: 0 - Move out of view
- Use
power3.ineasing - Faster duration
Hover Effects
- Keep duration short (0.3s)
- Use CSS transitions
- Reserve GSAP for complex hovers
Page Transitions
- Coordinate multiple elements
- Use timeline for sequencing
- Consider route changes
