比例
比例
[只读]补间动画的进度(一个介于 0 和 1 之间的值,其中 0.5 是中间点)之后经过ease
处理后得出的值。因此这个值可能会超出 0-1 的范围,例如在ease: "back"
或者ease: "elastic"
的情况下可以作为自定义插值的乘数使用,例如在onUpdate
回调函数轻松获取它。
细节
[只读] 补间动画的进度(一个介于 0 和 1 之间的值,其中 0.5 表示中间位置)之后经过ease
处理后得出的值。因此这个值可能会超出 0-1 的范围,例如在ease: "back"
或者ease: "elastic"
的情况下可以作为自定义插值的乘数使用,例如在onUpdate
回调函数轻松获取它。
因此,如果你有一个持续时间为一秒且缓动函数为"power2.out"
的补间动画,在 0.5 秒标记处(此时进度也是一半),tween.progress()
将返回 0.5,而tween.ratio
将返回 0.875。如下所示的代码,this.ratio
始终等于通过将补间动画的.progress()
传入缓动函数中可以得到的值。
const easeFunc = gsap.parseEase("power2.out");
const tween = gsap.to({ foo: 0 }, { foo: 10, duration: 1, ease: "power2.out" });
tween.pause(0.5); // pause at 0.5 seconds which is halfway in this 1-second tween
console.log(tween.progress()); // 0.5
console.log(tween.ratio); // 0.875
console.log(easeFunc(tween.progress())); // 0.875