animation-sequence-manager.js
1 export function runAnimationSequence(steps, onComplete) { 2 if (!steps || steps.length === 0) { 3 return []; 4 } 5 6 const timeoutIds = []; 7 let totalDelay = 0; 8 9 for (const step of steps) { 10 if (typeof step.callback !== 'function' || typeof step.delay !== 'number') { 11 continue; 12 } 13 14 totalDelay += step.delay; 15 const timeoutId = setTimeout(() => { 16 step.callback(); 17 }, totalDelay); 18 19 timeoutIds.push(timeoutId); 20 } 21 22 if (onComplete) { 23 const finalTimeoutId = setTimeout(onComplete, totalDelay); 24 timeoutIds.push(finalTimeoutId); 25 } 26 27 return timeoutIds; 28 }