gasp 安装
npm install gsap
引入
import gsap form 'gsap';
设置动画
gsap.to(cube.position,{ x:5, duration: 5, ease: 'power1.inOut',
onComplate:()=>{
//回调函数
console.log('动画完成')
},
onStart:()=>{
//回调函数
console.log('动画开始')
},
})
var animate1 = gsap.to(cube.rotation,{ x:2*Math.PI, duration: 5, ease: 'power1.inOut'
,onComplate:()=>{
//回调函数
console.log('动画开始')
},
repeat: 2, // 循环次数 无限循环:-1,
yoyo:true // 往还运动
delay: 2, // 延迟运动
})
window.addEventListener('dblclick',()=>{if(animate1.isActive()){
// 暂停动画
animate1.pause()}else{
// 启动
animate1.resume()
}
})