-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslideshowscript.js
More file actions
23 lines (18 loc) · 900 Bytes
/
slideshowscript.js
File metadata and controls
23 lines (18 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// setting the slidshow variables and funtion for index page
document.addEventListener("DOMContentLoaded", (event) => {
const slideshowImages = document.querySelectorAll('.intro .slideshow-img');
// set slideshow images to display in 3 second intervals
const nextImageDelay = 3000;
// start count for images to display
let currentImageCounter = 0;
slideshowImages[currentImageCounter].style.opacity = 1;
setInterval(nextImage, nextImageDelay);
function nextImage() {
// hide the current image to begin the slideshow
slideshowImages[currentImageCounter].style.opacity = 0;
// increment the counter to move to the next image
currentImageCounter = (currentImageCounter + 1) % slideshowImages.length;
// display the next image
slideshowImages[currentImageCounter].style.opacity = 1;
}
});