UNPKG

@erosnicolau/animated-text

Version:

Advanced React animated text component with comprehensive animation effects

43 lines (42 loc) 1.68 kB
// Default values export const DEFAULT_GROUP_CONFIG = { coordinationMode: 'parallel', groupStartDelay: 0, staggerDelay: 300, reduceMotionMode: 'respect', batchUpdates: true, debugMode: false, highlightGroup: false, logTiming: false, showReplay: false, showConfig: false }; export const DEFAULT_TIMING = { startDelay: 300, itemSpacing: 600, defaultDuration: 600, defaultEffect: 'fadeIn', // Properly named default defaultEasing: 'ease-out' }; // Font presets with responsive Tailwind classes export const FONT_PRESETS = { hero: 'text-5xl md:text-6xl lg:text-7xl', // Large titles section: 'text-3xl md:text-4xl lg:text-5xl', // Current default subsection: 'text-2xl md:text-3xl lg:text-4xl', // Smaller sections body: 'text-lg md:text-xl lg:text-2xl' // Large body text }; // Get delay for specific phrase export const getPhraseDelay = (index, styles, defaultSpacing = DEFAULT_TIMING.itemSpacing) => { const config = styles?.find(s => (Array.isArray(s.phrase) ? s.phrase.includes(index) : s.phrase === index)); return config?.delayBefore ?? (index - 1) * defaultSpacing; }; // Get animation config for phrase export const getPhraseAnimationConfig = (index, styles, defaults = DEFAULT_TIMING) => { const config = styles?.find(s => (Array.isArray(s.phrase) ? s.phrase.includes(index) : s.phrase === index)); return { effect: config?.effect ?? defaults.defaultEffect, duration: config?.duration ?? defaults.defaultDuration, delayBefore: config?.delayBefore ?? (index - 1) * defaults.itemSpacing, easing: config?.easing ?? defaults.defaultEasing }; };