mstickers/static/RenderImages.js
Kentai Radiquum edf51ec0f7
Improved watch script
- Added hot reload
- Added file serve via express
- Added cleanup on watch exit
2025-01-23 02:43:52 +05:00

20 lines
No EOL
598 B
JavaScript

const images = document.querySelectorAll("[data-image-id]");
images.forEach((image) => {
const spinner = document.querySelector(`[data-spinner-id="${image.getAttribute("data-image-id")}"]`)
if (image.height > 0) {
image.classList.remove("hidden");
spinner.classList.add("hidden");
return
}
image.addEventListener("load", () => {
console.log("image " + image.getAttribute("data-image-id") + " loaded");
image.classList.remove("hidden");
spinner.classList.add("hidden");
image.removeEventListener("load", this);
});
});