-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
80 lines (73 loc) · 2.35 KB
/
Copy pathscript.js
File metadata and controls
80 lines (73 loc) · 2.35 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const bikeContainer = document.querySelector(".bike");
const totalImages = 289;
let currentIndex = 0;
/*Adding Image 289 */
for (let i = 1; i <= totalImages; i++) {
const bikeImage = document.createElement("img");
bikeImage.src = `./downloaded_images/image_${i}.webp`;
bikeImage.alt = `Bike Image ${i}`;
bikeImage.classList.add("bike-image");
bikeContainer.appendChild(bikeImage);
}
const images = document.querySelectorAll(".bike-image");
/*Update Image Function */
function updateActiveImage(index) {
images.forEach((img, i) => {
img.classList.toggle("active", i === index);
});
// Handle text_area_1 visibility
const textArea1 = document.querySelector(".text_area_1");
if (index >= 51 && index <= 63) {
textArea1.style.display = "block";
} else {
textArea1.style.display = "none";
}
// Handle text_area_2 visibility
const textArea2 = document.querySelector(".text_area_2");
if (index >= 75 && index <= 110) {
textArea2.style.display = "block";
} else {
textArea2.style.display = "none";
}
// Handle text_area_3 visibility
const textArea3 = document.querySelector(".text_area_3");
if (index >= 155 && index <= 194) {
textArea3.style.display = "block";
} else {
textArea3.style.display = "none";
// Handle text_area_4 visibility
const textArea4 = document.querySelector(".text_area_4");
if (index >= 213 && index <= 240) {
textArea4.style.display = "block";
} else {
textArea4.style.display = "none";
}
}
// Handle text_area_5 visibility
const textArea5 = document.querySelector(".text_area_5");
if (index >= 271 && index <= 289) {
textArea5.style.display = "block";
} else {
textArea5.style.display = "none";
}
}
updateActiveImage(currentIndex);
/*Scrolling Option with Function*/
window.addEventListener("wheel", (event) => {
if (event.deltaY > 0) {
currentIndex = Math.min(currentIndex + 1, totalImages - 1);
} else {
currentIndex = Math.max(currentIndex - 1, 0);
}
updateActiveImage(currentIndex);
});
/*Scrolling Keydown with Function*/
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowDown") {
currentIndex = Math.min(currentIndex + 1, totalImages - 1);
updateActiveImage(currentIndex);
} else if (event.key === "ArrowUp") {
currentIndex = Math.max(currentIndex - 1, 0);
updateActiveImage(currentIndex);
}
});