.isActive()

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

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

.isActive()的参数

.isActive() 示例

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

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())
  }
}

.isActive()返回值

.isActive()的补充说明