当前位置: 首页 > 文档资料 > TweenMax 中文文档 >

.resume()

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

.resume( from:*, suppressEvents:Boolean ) : *
恢复播放而不改变方向(前进或后退),可选择首先跳到特定时间。

//恢复播放
myAnimation.resume();
 
//跳到第2秒并恢复播放
myAnimation.resume(2);
 
//跳到第2秒并恢复播放,并且不抑制事件触发
myAnimation.resume(2, false);

返回self,方便链式设置
.resume()适用于TweenMaxTweenLite

.resume()的参数

参数名类型必填说明
fromNum/label动画恢复播放之前跳转到的时间(或TimelineLite/TimelineMax的label)如果没有定义,它将从播放头当前的位置恢复播放。默认null
suppressEventsBoolean如果true(默认值),当播放头移动到from参数中定义的新位置时,不会触发任何事件或回调。

.resume() 示例


  






body {
	background-color: #f8f8f8;
	font-size: 16px;
}
#demo {
	width: 692px;
	height: 60px;
        background-color: #333;
	padding: 8px;
	margin-bottom: 10px;
}
.box {
	width: 50px;
	height: 50px;
	border-radius: 6px;
	margin-top: 4px;
	display: inline-block;
	position: absolute;
}
.green {
	background-color: #6fb936;
}
input[type="button"] {
	-webkit-appearance: button;
	padding: 8px;
	margin-right: 5px;
	margin-bottom: 5px;
}
box = document.getElementById("box"),
playBtn = document.getElementById("playBtn"),
pauseBtn = document.getElementById("pauseBtn"),
resumeBtn = document.getElementById("resumeBtn"),
reverseBtn = document.getElementById("reverseBtn"),
playFromBtn = document.getElementById("playFromBtn"),
reverseFromBtn = document.getElementById("reverseFromBtn"),
seekBtn = document.getElementById("seekBtn"),
timeScaleSlowBtn = document.getElementById("timeScaleSlowBtn"),
timeScaleNormalBtn = document.getElementById("timeScaleNormalBtn"),
timeScaleFastBtn = document.getElementById("timeScaleFastBtn"),
restartBtn = document.getElementById("restartBtn"),
tween = TweenLite.to(box, 6, {left:"632px", ease:Linear.easeNone});
playBtn.onclick = function() {
    //当前位置播放动画,如果动画播放完成, play() 无效
    tween.play();
}
pauseBtn.onclick = function() {
    tween.pause();
}
resumeBtn.onclick = function() {
    //当前位置继续动画.
    tween.resume();
}
resumeFromBtn.onclick = function() {
    //设置位置继续动画.
    tween.resume(3);
}
reverseBtn.onclick = function() {
    tween.reverse();
}
restartBtn.onclick = function() {
    //重新开始.
    tween.restart();
}

.resume()返回值

.resume()的补充说明