_onNext()

in src/core/GestureFeature.js [303:341]


  _onNext({layerName, animationName, canAdvance, isQueueEnd}) {
    // Exit if this isn't a managed layer
    const layer = this._managedLayers[layerName];
    if (layer === undefined) {
      return;
    }

    // Exit if it isn't a managed animation
    const animation = layer.animations[animationName];
    if (animation === undefined) {
      return;
    }

    // Start a new timer for looping states that aren't the end of the queue
    if (!canAdvance && !isQueueEnd && layer.currentGesture === animationName) {
      const holdTime = this._getHoldTime(layer, animation);
      layer.holdTimer.cancel();

      // Skip to the next animation right away if hold time is zero
      if (holdTime <= 0) {
        this._host.AnimationFeature.playNextAnimation(layerName, animationName);
      }

      // Wait for the given hold time before progressing
      else {
        layer.holdTimer = Utils.wait(holdTime, {
          onFinish: () => {
            // Advance the queue to the next state
            if (layer.currentGesture === animationName) {
              this._host.AnimationFeature.playNextAnimation(
                layerName,
                animationName
              );
            }
          },
        });
      }
    }
  }