UNPKG

@erosnicolau/animated-text

Version:

Advanced React animated text component with comprehensive animation effects

44 lines (43 loc) 1.79 kB
/** * Smart Performance Optimization Utils * Automatic animation fallback system when FPS performance mode is active */ import { isPerformanceModeActive } from './FPSPerformanceMonitor'; /** * Smart automatic fallback logic - replaces manual performance mode ternaries * Component specifies desired animation, system handles optimization transparently */ export const getOptimizedEffect = (effect) => { // If performance mode is not active, return original effect if (!isPerformanceModeActive()) { return effect; } // Smart automatic fallbacks based on effect complexity if (Array.isArray(effect)) { // For complex multi-effect arrays, simplify intelligently const stringEffects = effect.filter(e => typeof e === 'string'); const hasSimpleEffects = stringEffects.length > 0; if (hasSimpleEffects) { // Preserve one simple effect (fadeIn preferred) if (stringEffects.includes('fadeIn')) return ['fadeIn']; return [stringEffects[0]]; } else { // No simple effects, fallback to basic fadeIn return ['fadeIn']; } } // For single string effects, allow fadeIn and basic effects if (typeof effect === 'string') { const allowedSimpleEffects = ['fadeIn', 'fade']; return allowedSimpleEffects.includes(effect) ? effect : 'fadeIn'; } // For object effects (complex), fallback to fadeIn return 'fadeIn'; }; // Note: The following functions were removed as they were unused: // - getOptimizedDuration (duration optimization) // - getOptimizedSpacing (spacing optimization) // - getOptimizedStartDelay (delay optimization) // These can be re-implemented if needed for future performance features.