onRepeatParams
优质
小牛编辑
119浏览
2023-12-01
onRepeatParams: Array
传递给onRepeat
回调函数的参数数组。
new TimelineMax({onRepeat: myFunction, onRepeatParams: ["param1", "param2"]});
如果想传递时间轴对象本身,可使用{self}
,如 onRepeatParams:["{self}", "param2"]
onRepeatParams适用于TimelineMax
onRepeatParams的参数
onRepeatParams 示例
.box {
width:50px;
height:50px;
border-radius:6px;
margin-top:4px;
display:inline-block
}
.green{
background-color:#6fb936;
}
var tm= new TimelineMax({repeat: -1, onRepeat: onRepeat, onRepeatParams: ["{self}", "param2"]})
tm.to('.box', 2, {x: 500});
panel = document.getElementById("panel");
i = 1;
function onRepeat(param1, param2){
panel.innerHTML = i + param1 + param2;
i++;
//param1是此时间轴对象,param2是传递的字符串
}