.totalProgress()

.totalProgress( value:Number, suppressEvents:Boolean ) : *
获取或设置总的时间轴进程
var progress = myAnimation.totalProgress(); //读取总的时间轴进程
myAnimation.totalProgress(0.25); //设置总的时间轴进程
留空返回总的时间轴进程,设置则返回时间轴本身便于链式调用。
.totalProgress()适用于TimelineMaxTimelineLite

.totalProgress()的参数

参数 类型 必填 说明
value Number 设置总的progress或者留空读取总的progress,(default = NaN)
suppressEvents Boolean 如果true(default = false),当播放头移动到新位置时,不会触发任何事件或回调。

.totalProgress()效果展示

  • HTML
  • CSS
  • JS
  • 展示
duration: 0 单次动画持续的时间
totalDuration: 0 全部重复动画加重复间隔的持续时间
repeat: 0 of 重复次数
repeatDelay: 0 每次重复动画的间隔
time: 1 时间
totalTime: 1 总时间
progress: 1 单次动画进程
totalProgress: 1 总进程
body {
    background: #f8f8f8;
    font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #000;
    margin: 0 10px;
    padding: 0;
}
.box {
    width:50px;
    height:50px;
    border-radius:6px;
    margin-top:4px;
    display:inline-block
  }
.green{
    background-color:#6fb936;
  }
#stats{
    line-height:2;
margin-top:1em;
}
var tm = new TimelineMax({repeat: 3, repeatDelay:2, onUpdate:updateStats, onRepeat:updateReps, });
tm.to('.box', 3, {x: 500});

var duration = document.getElementById("duration"),
    totalDuration = document.getElementById("totalDuration"),
    repeatCount = document.getElementById("repeatCount"),
    repeatDelay = document.getElementById("repeatDelay"),
    totalRepeatCount = document.getElementById("totalRepeatCount"),
    time = document.getElementById("time"),
    totalTime = document.getElementById("totalTime"),
    progress = document.getElementById("progress"),
    totalProgress = document.getElementById("totalProgress"),
    reps = 0;

function updateReps() {
  reps++;
  repeatCount.innerHTML = reps;
}

function updateStats() {
  time.innerHTML = tm.time().toFixed(2);
  totalTime.innerHTML = tm.totalTime().toFixed(2);
  progress.innerHTML = tm.progress().toFixed(2);
  totalProgress.innerHTML = tm.totalProgress().toFixed(2);
}

function reset() {
  reps = 0;
  duration.innerHTML = tm.duration().toFixed(2);
  totalDuration.innerHTML = tm.totalDuration().toFixed(2);
  repeatCount.innerHTML = reps;
  repeatDelay.innerHTML = tm.repeatDelay().toFixed(2);
  totalRepeatCount.innerHTML = tm.repeat();
}

reset();

重播

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