onRepeat

优质
小牛编辑
119浏览
2023-12-01

onRepeat: Function
在每次时间轴重复播放时(repeat)执行。

new TimelineMax({onRepeat: myFunction});

onRepeat适用于TimelineMax

onRepeat的参数

onRepeat 示例


.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})
tm.to('.box', 2, {x: 500});
panel = document.getElementById("panel");
i=1;
function onRepeat(){
  panel.innerHTML = '函数触发了' + i + '次';
  i++;
}

onRepeat返回值

onRepeat的补充说明