onRepeatParams

onRepeatParams: Array
传递给onRepeat回调函数的参数数组。
new TimelineMax({onRepeat: myFunction, onRepeatParams: ["param1", "param2"]}); 
如果想传递时间轴对象本身,可使用{self},如 onRepeatParams:["{self}", "param2"]
onRepeatParams适用于TimelineMax

onRepeatParams效果展示

  • HTML
  • CSS
  • JS
  • 展示
.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是传递的字符串
}
重播

转载原创文章请注明:文章转载自:TweenMax中文网 [https://www.tweenmax.com.cn]
本文地址:https://www.tweenmax.com.cn/api/timelinemax/onRepeatParams