onStart

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

onStart: Function
当时间轴开始时执行的回调函数。
当前时间轴设置的delay会影响onStart的执行,但时间轴内的动画的delay不会影响动画在时间轴的开始时间。

new TimelineMax({onStart: myFunction});

onStart适用于TimelineMaxTimelineLite

onStart的参数

onStart 示例



.box {
    width:50px;
    height:50px;
    border-radius:6px;
    margin-top:4px;
    display:inline-block
  }
.green{
    background-color:#6fb936;
  }
var tm= new TimelineMax({delay: 2, onStart: onStart})
tm.to('.box', 2, {x: 500});
restartBtn = document.getElementById("restartBtn"),
restartBtn.onclick = function() {tm.restart();}
panel = document.getElementById("panel");
i=1;
function onStart(){
  panel.innerHTML='函数触发了'+i;
  i++;
}

onStart返回值

onStart的补充说明