Infinite self referring loop using setTimeout() stops unintentional

Infinite self referring loop using setTimeout() stops unintentional

Hello Community,

it's me again, can not see the wood for the trees. I want to repeat an image fade mechanism in an infinite loop. Here is the essential code snipped:
  1.     function sliderLoadNext () {   
           
            activeImageSliderEntry++;
            if ( activeImageSliderEntry == numberOfTitleImages ) { activeImageSliderEntry = 0 };
               
            loadUpcomingSliderEntry();
       
            setTimeout( sliderLoadNext , 3000 );
                               
        }

The function sliderLoadNext () is called elsewhere. Basically, I do have a div containing four other divs (with backgorund images, respectively). All the 4 divs are stored as objects in an array. So I want to set in the function above the new active element to fade it in using the function loadUpcomingSliderEntry(). So far, so good. The issue here is, that coming to the end of the available numbers of entries, I want the sequence to start all over from the beginning in an infinite loop. But the sequence is: 0 (start) --> 1 --> 2 --> 3 --> 0 --> SEQUENCE STOPS.

See the example here:

http://www.denkmalkonzepte.de/

The main title images in the top section should change infinitely.


Thanks

Frank