Animation System Architecture Guide
Animation System Architecture Guide
Overview
The site's animation system has been completely reorganized into a modular, performance-optimized architecture. This system provides smooth GSAP-powered animations, ScrollTrigger effects, and seamless page transitions.
File Structure
Core Animation System (/assets/js/animation/
)
animation-manager.js
(Core Controller)
- Purpose: Central GSAP and ScrollTrigger management
- Features:
- Performance optimization with frame throttling
- Mobile detection and reduced animations
- Memory cleanup and disposal
- Intersection Observer integration
- Responsive animation scaling
hero-animation.js
(Hero Coordinator)
- Purpose: Simplified hero section animation coordination
- Features:
- GSAP timeline management
- Progressive enhancement
- Error handling and fallbacks
- Integration with existing hero systems
scroll-utils.js
(ScrollTrigger Effects)
- Purpose: Advanced scroll-based animations
- Features:
- Parallax effects with performance optimization
- Reveal animations (fade, slide, scale)
- Progress indicators
- Smooth scroll implementation
- Viewport-aware animation triggers
coordinator.js
(System Controller)
- Purpose: Central coordination between all animation systems
- Features:
- SWUP page transition integration
- Component initialization coordination
- State management
- Performance monitoring
- Cleanup orchestration
Integration with Existing Systems
Page Transitions (SWUP)
- Animations automatically reinitialize on page changes
- Smooth coordination between exit/enter animations
- Preserves scroll position and state
Gallery System
- Coordinated with Swiper animations
- Lightbox integration with smooth transitions
- Progressive loading with animation triggers
Theme System
- Animations respect user's motion preferences
- Performance scaling for different devices
- Dark/light theme transition support
Performance Features
Optimization Strategies
- Frame Throttling: Limits animation updates to prevent performance issues
- Intersection Observer: Only animate elements in viewport
- Mobile Adaptation: Reduced complexity on mobile devices
- Memory Management: Automatic cleanup of completed animations
- Progressive Enhancement: Graceful fallbacks for older browsers
Loading Strategy
<!-- Load order in scripts.html -->
1. animation-manager.js (core system)
2. hero-animation.js (hero coordinator)
3. scroll-utils.js (scroll effects)
4. coordinator.js (system controller)
Usage Examples
Basic ScrollTrigger Animation
// Automatically handled by scroll-utils.js
<div class="animate-reveal" data-animation="fade-up">
Content to animate
</div>
Custom Animation Integration
// Use the AnimationManager for custom animations
if (window.AnimationManager) {
AnimationManager.createTimeline('custom-animation', {
targets: '.my-element',
duration: 1,
ease: 'power2.out'
});
}
Performance Monitoring
// Check animation performance
if (window.AnimationCoordinator) {
const stats = AnimationCoordinator.getPerformanceStats();
console.log('Active animations:', stats.activeCount);
}
Migration from Old System
Replaced Files
animations-optimized.js
→animation-manager.js
+scroll-utils.js
hero-animations.js
→hero-animation.js
(simplified)- Scattered animation code → Centralized in
/animation/
directory
Benefits of New Architecture
- Modularity: Clear separation of concerns
- Maintainability: Easier to debug and extend
- Performance: Better optimization and cleanup
- Scalability: Easy to add new animation types
- Integration: Better coordination with other systems
Troubleshooting
Common Issues
- Animations not triggering: Check if ScrollTrigger is properly initialized
- Performance issues: Verify frame throttling is enabled
- Mobile problems: Ensure mobile detection is working
- Memory leaks: Check cleanup methods are being called
Debug Mode
Enable debug logging by adding to console:
window.AnimationManager.debug = true;
Future Enhancements
Planned Features
- Animation Presets: Pre-built animation combinations
- Visual Builder: GUI for creating complex animations
- Performance Analytics: Real-time performance monitoring
- A/B Testing: Animation variant testing system
- Accessibility: Enhanced motion sensitivity controls
Extension Points
- Custom scroll effects in
scroll-utils.js
- New animation types in
animation-manager.js
- Integration hooks in
coordinator.js
Last Updated: Animation system reorganization completion Related: CONTRAST-ZONES-GUIDE.md, CSS-README.md