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

.restart()

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

.restart( includeDelay:Boolean, suppressEvents:Boolean ) : *
重新开始动画/重头开始。

//略去delay马上重新开始
myAnimation.restart();
 
//包含delay重新开始,并且不抑制事件触发
myAnimation.restart(true, false);

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

.restart()的参数

参数名类型必填说明
includeDelayBoolean设置重新开始动画时是否包含延迟(如果有),例如动画 new TweenLite(mc, 2, {x:100, delay:1});
当你restart(),他会略过delay马上开始。如果是restart(true),则会有1秒的延迟。默认false。
suppressEventsBoolean如果true(默认值),当播放头移动到新位置时,不会触发任何事件或回调。

.restart() 示例


  


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"),
restartBtn = document.getElementById("restartBtn"),
restartBtn2 = document.getElementById("restartBtn2"),
tween = TweenLite.to(box, 6, {left:"632px",delay:2});
restartBtn.onclick = function() {
    //重新开始.
    tween.restart();
}
restartBtn2.onclick = function() {
    //重新开始.
    tween.restart(true);
}

.restart()返回值

.restart()的补充说明