Skip to Content
Welcome to Vyno! 🍷

.by()

相对动画,基于当前值的偏移。

函数签名

by(offset: PixiProperty, options?: GsapOptions): Figure

基础用法

// 向右移动 100 像素 figure.by({ x: 100 }); // 向左上移动 figure.by({ x: -50, y: -30 }); // 放大 20% figure.by({ scaleX: 0.2, scaleY: 0.2 });

动画选项

figure.by( { x: 100 }, { duration: 0.5, ease: "power2.out", } );

与 .to() 的区别

方法效果
.to({ x: 100 })移动到 x=100
.by({ x: 100 })向右移动 100 像素
// 假设当前 x=200 figure.to({ x: 100 }); // 移动到 x=100 figure.by({ x: 100 }); // 移动到 x=300 (200+100)

链式调用

figure.by({ x: 100 }).speak`我向右移动了`;
Last updated on