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";
const child = entry.querySelector("img[data-thumb-img]");
const isLoaded = child && child.complete && child.naturalHeight !== 0;
if (child && !isLoaded) {
child.style.opacity = 0;
child.addEventListener("load", () => {
child.style.transition = "opacity 0.3s ease";
child.style.opacity = 1;
});
}
setTimeout(() => {
const isLoaded = child && child.complete && child.naturalHeight !== 0;
console.log(isLoaded, child.getAttribute("src"));
if (child && !isLoaded) {
child.style.opacity = 0;
child.addEventListener("load", () => {
child.style.transition = "opacity 0.3s ease";
child.style.opacity = 1;
});
}
}, 50);
});