onRepeatParams
优质
小牛编辑
131浏览
2023-12-01
onRepeatParams: Array
传递给onRepeat
事件函数的参数数组,例如
TweenMax.to(mc, 1, {
x:100,
onRepeat:myFunction,
onRepeatParams:[mc, "param2"]
});
如果想传递动画对象本身,可以使用{self}
onRepeatParams:["{self}", "param2"]
onRepeatParams适用于TweenMax
onRepeatParams的参数
onRepeatParams 示例
重复次数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;
new TweenMax('.box', 3, {
x: 500,
repeat: -1,
yoyo: true,
onRepeatParams:["{self}", "param2"],
onRepeat:myFunction,
});
function myFunction(param1,param2){
num.innerHTML=count;
console.log(param1);
count++;
}