need help with looping

Hi, @ravinderjassar !!

For now, how about trying an implementation like this?
Since it was a simple change, I had AI help me out a bit. I think it should work. :innocent:

$w('#dataset1').onReady(() => {

  $w('#repeaterDesigns').onItemReady(($item, itemData) => {

    const mediaGallery = itemData.mediagallery;

    if (Array.isArray(mediaGallery) && mediaGallery.length > 0) {

      const imageElement = $item('#ThumbnailFromGallery');
      let currentIndex = 0;

      const loopImages = () => {
        imageElement.src = mediaGallery[currentIndex].src;
        currentIndex = (currentIndex + 1) % mediaGallery.length;
        setTimeout(loopImages, 2000);
      };

      loopImages();

    } else {
      console.warn('Media gallery is empty or not an array for item:', itemData);
    }

  });

});

1 Like