-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
function orderNow() { | ||
alert("Order Now feature coming soon!"); | ||
} | ||
|
||
|
||
|
||
const popup = document.getElementById('popup'); | ||
const closePopupButton = document.getElementById('closePopup'); | ||
const images = document.querySelectorAll('.image-slider img'); | ||
let currentIndex = 0; | ||
|
||
function showImage(index) { | ||
images.forEach((img, i) => { | ||
img.classList.remove('active'); | ||
if (i === index) { | ||
img.classList.add('active'); | ||
} | ||
}); | ||
} | ||
|
||
function nextImage() { | ||
currentIndex = (currentIndex + 1) % images.length; | ||
showImage(currentIndex); | ||
} | ||
|
||
function startSlider() { | ||
showImage(currentIndex); | ||
setInterval(nextImage, 1000); // Change image every 3 seconds | ||
} | ||
|
||
// Show popup on page load | ||
window.addEventListener('load', () => { | ||
popup.style.display = 'flex'; | ||
startSlider(); | ||
}); | ||
|
||
closePopupButton.addEventListener('click', () => { | ||
popup.style.display = 'none'; | ||
}); | ||
|
||
// Close popup if clicked outside of the content | ||
window.addEventListener('click', (event) => { | ||
if (event.target === popup) { | ||
popup.style.display = 'none'; | ||
} | ||
}); |