.reversed()

.reversed( value:Boolean ) : *
获取或设置动画的反转状态,指示是否应该反向播放动画。
var rev = myAnimation.reversed(); //获取反方向状态
myAnimation.reversed( true ); //设置反方向
myAnimation.reversed( !myAnimation.reversed() ); //切换方向
返回self,方便链式调用。
.reversed()适用于TimelineMaxTimelineLite

.reversed()的参数

参数名 类型 必填 说明
value Boolean 省略参数返回当前反方向状态(getter),而定义参数则设置值(setter)并返回实例本身以便于链式设置

.reversed()效果展示

  • HTML
  • CSS
  • JS
  • 展示
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;
}
var tm = new TimelineMax();
tm.to('.box', 6, {x: 500});

playBtn = document.getElementById("playBtn");
reverseToggleBtn = document.getElementById("reverseToggleBtn");
playBtn.onclick = function() {
    tm.play();
}
reverseToggleBtn.onclick = function() {
    tm.reversed( !tm.reversed() );
}
重播

转载原创文章请注明:文章转载自:TweenMax中文网 [https://www.tweenmax.com.cn]
本文地址:https://www.tweenmax.com.cn/api/timelinemax/reversed()