Capítulo 178 de 411
A helper for cases where the full timeline can't be pre-built up front because each step's animation depends on running a function first (e.g. changing state) and must fully complete before the next step's function runs; it lets you express that as a flat sequence of functions and optional delays.
progressiveBuild(step1, step2, delayNumber, step3, ...) — each function returns the tween/timeline for that step; a bare number between two functions becomes a delay before the next step's added.onComplete that pulls the next function/delay off the argument list and appends its result to the timeline with "+=" + delay.function progressiveBuild() {
let data = Array.from(arguments), i = 0,
tl = gsap.timeline({
onComplete: function () {
let isNum = typeof data[i] === "number",
delay = isNum ? data[i++] : 0,
func = data[i++];
typeof func === "function" && tl.add(func(), "+=" + delay);
},
});
tl.vars.onComplete();
return tl;
}
progressiveBuild(step1, step2, 1.5, step3);
timeline.add() sequence is simpler.