-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
37 lines (32 loc) · 851 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const slides = document.querySelectorAll(".stack img");
let counter = 0;
const totalSlides = slides.length; // Total number of slides
// Set the initial position of each slide
slides.forEach((slide, index) => {
slide.style.left = `${index * 100}%`;
});
const previous = () => {
if (counter > 0) {
// Check if not at the first slide
counter--;
slideImage();
}
};
const next = () => {
if (counter < totalSlides - 1) {
// Check if not at the last slide
counter++;
slideImage();
}
};
const slideImage = () => {
slides.forEach((slide) => {
slide.style.transform = `translateX(-${counter * 100}%)`;
});
};
function toggleMenu() {
const menu = document.querySelector(".menu-links");
const icon = document.querySelector(".hamburger-icon");
menu.classList.toggle("open");
icon.classList.toggle("open");
}