Spaces:
Running
Running
Improved Performance
Browse files- index.html +18 -6
index.html
CHANGED
@@ -808,14 +808,26 @@
|
|
808 |
});
|
809 |
|
810 |
function updateMenuImage() {
|
|
|
811 |
menuImage.classList.remove('flip-in');
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
|
|
|
|
|
|
817 |
currentPageDisplay.textContent = currentPage;
|
818 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
819 |
}
|
820 |
|
821 |
// Smooth scrolling for navigation links
|
|
|
808 |
});
|
809 |
|
810 |
function updateMenuImage() {
|
811 |
+
// Remove the animation class to reset the effect
|
812 |
menuImage.classList.remove('flip-in');
|
813 |
+
|
814 |
+
// Create a new image element to preload the next page
|
815 |
+
const newImg = new Image();
|
816 |
+
newImg.src = `img/CANIE MENU_page_${currentPage}.png`;
|
817 |
+
|
818 |
+
// When the new image is loaded, update the menu image and apply the animation
|
819 |
+
newImg.onload = () => {
|
820 |
+
menuImage.src = newImg.src;
|
821 |
currentPageDisplay.textContent = currentPage;
|
822 |
+
// Trigger a reflow to restart the animation and add the class back
|
823 |
+
void menuImage.offsetWidth;
|
824 |
+
menuImage.classList.add('flip-in');
|
825 |
+
};
|
826 |
+
|
827 |
+
// Optionally, handle errors if the image fails to load
|
828 |
+
newImg.onerror = () => {
|
829 |
+
console.error('Failed to load image:', newImg.src);
|
830 |
+
};
|
831 |
}
|
832 |
|
833 |
// Smooth scrolling for navigation links
|