Skip to content

Commit

Permalink
preload images
Browse files Browse the repository at this point in the history
  • Loading branch information
ekqiu committed May 4, 2024
1 parent 3ddabee commit 05647cc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,22 @@ async function shareImage(imageUrl) {
}
// TODO implements a fallback to download the file
}

function preloadImages() {
let imageUrls = [];
// Collect all the image URLs from the storyline and questions arrays
for (let i = 0; i < storyline.length; i++) {
imageUrls.push(`images/${storyline[i][1]}`);
}
for (let i = 0; i < questions.length; i++) {
imageUrls.push(`images/${questions[i][1]}`);
}
// Preload the images
for (let i = 0; i < imageUrls.length; i++) {
let img = new Image();
img.src = imageUrls[i];
}
}

// Call the preloadImages function to preload the images
preloadImages();

0 comments on commit 05647cc

Please sign in to comment.