Riku
2025-06-11 5679cbbb630092a197d991cb41997a2d953261e9
src/model/FrameAnimation.js
@@ -17,6 +17,7 @@
  this.isPause = false;
  this.isRunning = false;
  this.isStop = true;
  // 是否开启动态绘制速度
  this.dynamicSpeed = false;
  // 每个任务耗时(秒)
@@ -27,12 +28,13 @@
FrameAnimation.prototype = {
  start: function () {
    if (this.intervalFlag != undefined) {
      this.isPause = false;
    } else {
      this.isRunning = true;
    // 不存在动画任务时重新开始,否则继续
    if (this.intervalFlag == undefined) {
      this._doTask();
    }
    this.isPause = false;
    this.isStop = false;
    this.isRunning = true;
  },
  /**
   * 动态动画速度
@@ -65,8 +67,11 @@
  },
  pause: function () {
    this.isPause = true;
    this.isRunning = false;
  },
  stop: function () {
    if (this.isStop) return;
    if (this.intervalFlag != undefined) {
      clearInterval(this.intervalFlag);
      this.intervalFlag = undefined;
@@ -85,7 +90,9 @@
    this.isRunning = false;
    this.isPause = false;
    this.isStop = true;
    this.lastestTime = undefined;
    this.speed = 1;
  },
  setOnStopCallback: function (callback) {
    this.onStopCallback = callback;
@@ -118,14 +125,15 @@
        if (this.isPause) {
          return;
        }
        if (index >= t.count) {
        // 绘制3D图形时,最少需要2个点才可绘制图形
        // 因此此处索引只到倒数第二个点就结束
        if (index >= t.count - 1) {
          this._endTask(this.intervalFlag);
          return;
        }
        t.task(t.data, index, t.count);
        index += this.speed;
        // console.log("_doTask:" + index);
      }, this.timeout);
    }
  },