From c904b2b71e1b2ae141ace3eec2c5f55b3368efbf Mon Sep 17 00:00:00 2001 From: FURK4NGG <105324908+FURK4NGG@users.noreply.github.com> Date: Sat, 5 Oct 2024 19:27:42 +0300 Subject: [PATCH] Update 1.js --- JAVASCRIPT/tr/1.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/JAVASCRIPT/tr/1.js b/JAVASCRIPT/tr/1.js index bc657c1..89276b3 100644 --- a/JAVASCRIPT/tr/1.js +++ b/JAVASCRIPT/tr/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');