I'm currently looping a list of images. Below is what I have so far. I'm not able to properly randomize the list.
Also, how can I go about transitioning to next image. I want to my images to smoothly fade into the next image instead of just quickly changing the image to next.
HTML
<div class="TestRotator">
<img height="170" id="rotator" class="img-fluid, image-hover" alt="Responsive image"/>
</div>
<script src="js_src/art-imagechanger.js"></script>
JS
(function () {
var rotator = document.getElementById("rotator");
var imageDir = ['https://vignette.wikia.nocookie.net/birds/images/0/09/Birds-01.jpg','https://nas-national-prod.s3.amazonaws.com/styles/hero_mobile/s3/h_a1_7443_5_painted-bunting_julie_torkomian_adult-male.jpg','https://www.allaboutbirds.org/news/wp-content/uploads/2020/07/STanager-Shapiro-ML.jpg',];
var i = 0;
function loop() {
if(i > (imageDir.length - 1)){
i = 0;
}
var r = rotator.src = imageDir[i];
Math.floor(Math.random() * r)
i++;
loopTimer = setTimeout(loop ,3000);
}
loop();
})();