onRepeat
优质
小牛编辑
133浏览
2023-12-01
onRepeat: Function
在每次动画重复时(repeat
)执行此事件函数。
TweenMax.to('.box', 2, {
x: 500,
repeat:1,
onRepeat:function(){
...
}
});
onRepeat适用于TweenMaxonRepeat的参数
onRepeat 示例
重复次数0
body {
background: #f8f8f8;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 14px;
color: #000;
margin: 0 10px;
padding: 0;
}
.box {
width:50px;
height:50px;
border-radius:6px;
margin-top:4px;
display:inline-block
}
.green{
background-color:#6fb936;
}
TweenMax.killAll();
var num = document.getElementById("num");
count = 1;
var tween = new TweenMax('.box', 3, {
x: 500,
repeat: -1,
yoyo: true,
onRepeat: function(){
num.innerHTML=count;
count++;
},
});