mstickers/static/RenderImages.js

22 lines
No EOL
646 B
JavaScript

const images = document.querySelectorAll("[data-image-id]");
images.forEach((image) => {
const spinner = document.querySelector(`[data-spinner-id="${image.getAttribute("data-image-id")}"]`)
console.log(image)
console.log(spinner)
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);
});
});