.addCallback( callback:Function, position:*, params:Array, scope:* ) : TimelineMax
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
callback | Function | 是 | 要执行的函数 |
position | * | 否 |
插入回调函数的位置。秒或帧或标签,默认为"+=0" 。例如:
|
params | Array | 否 | 传递回调的参数数组。default = null |
scope | * | 否 | 回调调用的范围(基本上代表函数中"this"指的是什么),default = null |
.box {
width:50px;
height:50px;
border-radius:6px;
margin-top:4px;
}
.green{
background-color:#6fb936;
}
panel= document.getElementById("panel");
myFunction = function(){
panel.innerHTML='函数触发了!';
}
var tm = new TimelineMax();
tm.to(".box", 5, {x:500})
.addCallback(myFunction,"-=4");
console.log(tm.getChildren());
getChildren()
,将会为每个回调函数返回一个动画(tween),你可以通过这些动画的vars.onComplete
的内容并且duration
为零来识别出这些回调函数。call()
方法会更简洁 。此外,add()
方法也可以添加回调,但 add()
不接受参数。
转载原创文章请注明:文章转载自:TweenMax中文网 [https://www.tweenmax.com.cn]
本文地址:https://www.tweenmax.com.cn/api/timelinemax/addCallback()