onRepeatParams

onRepeatParams: Array
传递给onRepeat事件函数的参数数组,例如
 TweenMax.to(mc, 1, {
    x:100, 
    onRepeat:myFunction, 
    onRepeatParams:[mc, "param2"]
});
如果想传递动画对象本身,可以使用{self}
onRepeatParams:["{self}", "param2"]
onRepeatParams适用于TweenMax

onRepeatParams效果展示

  • HTML
  • CSS
  • JS
  • 展示
重复次数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++; 
    }
重播

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