- TimelineMax 中文手册 / TimelineLite 中文手册
- TimelineMax()
- .add()
- .addCallback()
- .addLabel()
- .addPause()
- .remove()
- .removeCallBack()
- .removeLabel()
- .removePause()
- .to()
- .from()
- .fromTo()
- .staggerTo()
- .staggerFrom()
- .staggerFromTo()
- .set()
- delay
- paused
- useFrames
- tweens
- stagger
- align
- autoRemoveChildren
- smoothChildTiming
- repeat
- repeatDelay
- yoyo
- callbackScope
- onStart
- onStartParams
- onStartScope
- onComplete
- onCompleteParams
- onCompleteScope
- onReverseComplete
- onReverseCompleteParams
- onReverseCompleteScope
- onUpdate
- onUpdateParams
- onUpdateScope
- onRepeat
- onRepeatParams
- onRepeatScope
- .play()
- .pause()
- .paused()
- .restart()
- .resume()
- .reverse()
- .reversed()
- .seek()
- .timeScale()
- .tweenTo()
- .tweenFromTo()
- .delay()
- .repeat()
- .repeatDelay()
- .duration()
- .totalDuration()
- .progress()
- .totalProgress()
- .time()
- .totalTime()
- .endTime()
- .startTime()
- .yoyo()
- .autoRemoveChildren
- .data
- .smoothChildTiming
- .timeline
- .call()
- .clear()
- .currentLabel()
- .eventCallback()
- TimelineMax.exportRoot()
- .getActive()
- .getChildren()
- .getLabelAfter()
- .getLabelBefore()
- .getLabelsArray()
- .getLabelTime()
- .getTweensOf()
- .invalidate()
- .isActive()
- .kill()
- .recent()
- .shiftChildren()
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
.call()
.call( callback:Function, params:Array, scope:*, position:* ) : *
在时间轴的末尾(或position
位置)增加一个回调函数,作用类似于add( TweenLite.delayedCall(...) )
,以下代码效果大致相同:
myTimeline.add( TweenLite.delayedCall(0, myFunction, ["param1", "param2"]) );
myTimeline.call(myFunction, ["param1", "param2"]);
call与onComplete
的区别在于,onComplete
会在时间轴全部完成后触发,而call会在设定时的时间轴末端触发。
例如你的时间轴长为1秒,那么call设置的函数会在1秒时触发。这时你增加了一个1秒的动画使时间轴变成了2秒,call函数还是在1秒时触发,而onComplete
则会在2秒时触发。
使用position
设置函数触发时间点:
tl.call(func, ["param1"]); //添加到时间轴末端
tl.call(func, ["param1"], this, 2); //添加到时间轴2秒处(绝对位置)
tl.call(func, ["param1"], this, "+=2"); //添加到时间轴后2秒处(相对位置)
tl.call(func, ["param1"], this, "myLabel"); //添加至标签"myLabel"处
tl.call(func, ["param1"], this, "myLabel+=2"); //添加至标签"myLabel"后2秒处
.call()适用于TimelineMaxTimelineLite
.call()的参数
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
callback | Function | 是 | 要执行的函数 |
params | Array | 否 | 传递回调的参数数组。default = null |
scope | * | 否 | 回调调用的范围(基本上代表函数中"this"指的是什么),default = null |
position | * | 否 | 插入回调函数的位置。秒或帧或标签,默认为"+=0" 。例如: |
.call() 示例
.box {
width:50px;
height:50px;
border-radius:6px;
margin-top:4px;
}
.green{
background-color:#6fb936;
}
var tm = new TimelineMax();
tm.to(".box", 5, {x: 500}).call(myFunction, null, this, "-=4");
panel= document.getElementById("panel");
function myFunction(){
panel.innerHTML='函数触发了!';
}
.call()返回值
.call()的补充说明
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论