play around with image loading

This commit is contained in:
max_richter 2023-08-11 17:50:00 +02:00
parent d4db8430e4
commit d2a02fcf34

View File

@ -246,12 +246,15 @@ document.querySelectorAll("[data-thumb]").forEach((entry) => {
entry.style.backgroundSize = "cover"; entry.style.backgroundSize = "cover";
const child = entry.querySelector("img[data-thumb-img]"); const child = entry.querySelector("img[data-thumb-img]");
const isLoaded = child && child.complete && child.naturalHeight !== 0; setTimeout(() => {
if (child && !isLoaded) { const isLoaded = child && child.complete && child.naturalHeight !== 0;
child.style.opacity = 0; console.log(isLoaded, child.getAttribute("src"));
child.addEventListener("load", () => { if (child && !isLoaded) {
child.style.transition = "opacity 0.3s ease"; child.style.opacity = 0;
child.style.opacity = 1; child.addEventListener("load", () => {
}); child.style.transition = "opacity 0.3s ease";
} child.style.opacity = 1;
});
}
}, 50);
}); });