Skip to Content
Welcome to Vyno! 🍷

.to()

补间动画,从当前状态平滑过渡到目标状态。基于 GSAP 实现。

函数签名

to(target: PixiProperty, options?: GsapOptions): Figure

基础用法

// 移动到指定位置 figure.to({ x: 500, y: 200 }); // 改变透明度 figure.to({ alpha: 0.5 }); // 缩放 figure.to({ scaleX: 1.5, scaleY: 1.5 });

动画选项

figure.to( { x: 500 }, { duration: 1, // 持续时间(秒) ease: "power2.out", // 缓动函数 delay: 0.5, // 延迟(秒) } );

GsapOptions

属性类型描述
durationnumber动画持续时间(秒)
easestring缓动函数
delaynumber延迟时间(秒)

常用缓动函数

缓动效果
"none"线性
"power1.out"缓出
"power2.out"强缓出
"elastic.out"弹性
"bounce.out"弹跳

链式调用

// 移动后说话 figure.to({ x: 500 }).speak`我移动了`; // 组合动画 figure.to({ x: 500 }).to({ alpha: 0.5 });

中断支持

动画可被 interrupt 事件中断,中断时会跳到最终状态。

Last updated on