Capítulo 166 de 411
A helper that inverts an ease function: given a target eased output ratio (like 0.7), it numerically solves for the linear progress (0-1) that produces it, useful for syncing other logic to a specific point in an eased animation.
precision parameter (default 0.0001) to control how close the approximation must get.function easeToLinear(ease, ratio, precision = 0.0001) {
ease = gsap.parseEase(ease);
let t = 0, dif = ratio - ease(t), inc = dif / 2, newDif;
while (Math.abs(dif) > precision) {
newDif = ratio - ease((t += inc));
newDif < 0 !== inc < 0 && (inc *= Math.max(-0.5, newDif / dif));
dif = newDif;
}
return t + ((ratio - ease(t + inc)) / dif) * -inc;
}
// where does a 100->500 tween eased with "power2.out" cross 250?
let progress = easeToLinear("power2", (250 - 100) / (500 - 100), 0.00001);
parseEase.