play()

in src/core/animpack/state/QueueState.js [142:177]


  play(onFinish, onError, onCancel, onNext) {
    const name = this._reset();
    super.play(onFinish, onError, onCancel);

    if (this._done) {
      this._promises.finish.resolve();
    } else {
      // Signal the next animation is starting
      if (name !== this.currentAnimation && typeof onNext === 'function') {
        const lastName = [...this._states.keys()][this._states.size - 1];
        const isQueueEnd = name === lastName;
        onNext({
          name,
          canAdvance: name
            ? this.getState(name).loopCount !== Infinity && !isQueueEnd
            : true,
          isQueueEnd: !name || isQueueEnd,
        });
      }

      // Start the next animation
      this.playAnimation(
        name,
        this._currentState ? this._transitionTime : 0,
        this._easingFn,
        () => {
          if (!this._paused && !this.isTransitioning) {
            this.next(onNext);
          }
        },
        onError
      );
    }

    return this._promises.finish;
  }