code: function setAutoPlayLoop() {
      intervalStartTime = now();
      interval = setTimeout(() => {
        intervalStartTime = now();
        remainingTime = delay; // resets time, used by pause/resume logic
  
        change(nextIndex());
  
        // loops
        setAutoPlayLoop();
      }, remainingTime);
    }
docs: Slideshow/autoPlay timing logic