clean project-slideshow script
This commit is contained in:
parent
1b108ac44f
commit
4dd4834aeb
3 changed files with 3 additions and 28 deletions
|
|
@ -1,25 +0,0 @@
|
|||
document.querySelectorAll(".project-slideshow").forEach((slideshow) => {
|
||||
function goToNextSlide() {
|
||||
const currentSlide = document.querySelector(".project-images .active");
|
||||
const slideToShow = currentSlide.nextElementSibling
|
||||
? currentSlide.nextElementSibling
|
||||
: document.querySelector(".project-images img");
|
||||
|
||||
currentSlide.classList.toggle("active");
|
||||
slideToShow.classList.toggle("active");
|
||||
}
|
||||
|
||||
const images = slideshow.querySelector(".project-images");
|
||||
const prevButton = slideshow.querySelector(".prev");
|
||||
const nextButton = slideshow.querySelector(".next");
|
||||
|
||||
nextButton.addEventListener("click", () => {
|
||||
goToNextSlide();
|
||||
});
|
||||
|
||||
prevButton.addEventListener("click", () => {
|
||||
currentIndex =
|
||||
(currentIndex - 1 + images.children.length) % images.children.length;
|
||||
goToPrevSlide();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue