Spaces:
Running
Running
Update index.html
Browse files- index.html +13 -1
index.html
CHANGED
@@ -18,9 +18,21 @@
|
|
18 |
const numImages = 240; // Number of images
|
19 |
const imageContainer = document.querySelector('.image-container');
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
// Function to get the correct image number based on scroll position
|
22 |
function getImageForScroll(scrollPos) {
|
23 |
-
let imageIndex = Math.floor(scrollPos /
|
24 |
return imageIndex < numImages ? String(imageIndex + 1).padStart(4, '0') : String(numImages).padStart(4, '0');
|
25 |
}
|
26 |
|
|
|
18 |
const numImages = 240; // Number of images
|
19 |
const imageContainer = document.querySelector('.image-container');
|
20 |
|
21 |
+
// Preload all images
|
22 |
+
function preloadImages() {
|
23 |
+
for (let i = 1; i <= numImages; i++) {
|
24 |
+
const img = new Image();
|
25 |
+
const imageNumber = String(i).padStart(4, '0');
|
26 |
+
img.src = `images/${imageNumber}.png`;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
// Call preloadImages when the page loads
|
31 |
+
window.onload = preloadImages;
|
32 |
+
|
33 |
// Function to get the correct image number based on scroll position
|
34 |
function getImageForScroll(scrollPos) {
|
35 |
+
let imageIndex = Math.floor(scrollPos / 20); // Change every 20 pixels
|
36 |
return imageIndex < numImages ? String(imageIndex + 1).padStart(4, '0') : String(numImages).padStart(4, '0');
|
37 |
}
|
38 |
|