From 79f7cd0c6dbf63d7d8ea48ea7a950fe256f2ea58 Mon Sep 17 00:00:00 2001 From: FURK4NGG <105324908+FURK4NGG@users.noreply.github.com> Date: Sat, 5 Oct 2024 17:43:57 +0300 Subject: [PATCH] Update 1.js --- JAVASCRIPT/1.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/JAVASCRIPT/1.js b/JAVASCRIPT/1.js index 4f4d4cb..353d280 100644 --- a/JAVASCRIPT/1.js +++ b/JAVASCRIPT/1.js @@ -1,3 +1,21 @@ +/*IMAGE CHANGER*/ +let currentIndex = 0; +const images = document.querySelectorAll('#photo img'); + +function switchPhoto() { + // Hide the current image by removing 'visible' + images[currentIndex].classList.remove('visible'); + + // Increment the index and loop back to the first image after the last one + currentIndex = (currentIndex + 1) % images.length; + + // Show the next image by adding 'visible' + images[currentIndex].classList.add('visible'); +} + +// Initially set the first image as visible +images[currentIndex].classList.add('visible'); + /*SCROLL REVEALING*/ document.addEventListener('DOMContentLoaded', () => { const textContainer = document.getElementById('animatedTextContainer');