code: function scrollWithoutSkipping(stackData, pendingEvent, element) {
    if (stackData.pending[0] === pendingEvent) {
      if (stackData.currentImageIdIndex === pendingEvent.index) {
        stackData.pending.splice(stackData.pending.indexOf(pendingEvent), 1);
  
        if (stackData.pending.length > 0) {
          scrollWithoutSkipping(stackData, stackData.pending[0], element);
        }
  
        return;
      }
  
      const newImageHandler = function(event) {
        const index = stackData.imageIds.indexOf(event.detail.image.imageId);
  
        if (index === pendingEvent.index) {
          stackData.pending.splice(stackData.pending.indexOf(pendingEvent), 1);
          element.removeEventListener(
            external.cornerstone.EVENTS.NEW_IMAGE,
            newImageHandler
          );
  
          if (stackData.pending.length > 0) {
            scrollWithoutSkipping(stackData, stackData.pending[0], element);
          }
        }
      };
  
      element.addEventListener(
        external.cornerstone.EVENTS.NEW_IMAGE,
        newImageHandler
      );
  
      scrollToIndex(element, pendingEvent.index);
    }
  }
docs: Recursively scrolls the stack until the desired image is reached.
  @private
  @method
  @name scrollWithoutSkipping
  
  @param  {type} stackData    Data object containing information about the stack.
  @param  {Object} pendingEvent The event to process next.
  @param  {HTMLElement} element      The element being scrolled through.
  @returns {void}