.isActive()

.isActive( ) : Boolean
指示动画当前是否处于活动状态(意味着播放头在此实例的时间范围内正在活动,并且未暂停,也不是其任何祖先时间轴)。
.isActive()适用于TimelineMaxTimelineLite

.isActive()效果展示

  • HTML
  • CSS
  • JS
  • 展示

只有在静止状态下才能反转动画方向

body, html {
  font-family: Signika Negative, sans-serif;
  background: #111;
  color:#efefef;
}

.wrapper {
  width:400px;
  height:100px;
  background:#444;
  margin-bottom:10px;
}

.box {
  width:100px;
  height:100px;
  background:#88ce02;
}

button {
  margin:10px 0;
  padding:10px;
}
var endX = 300;
var tm = new TimelineMax();
tm.to('.box', 2, {x:endX, ease:Linear.easeNone}).reverse();

tweenBox=document.getElementById("tweenBox")
tweenBox.onclick=function(){
  if(!tm.isActive()){
    //只有在tween is not active状态下才能反转动画方向
    tm.reversed(!tm.reversed())
  }
}
重播

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