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,7 +246,9 @@ 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]");
setTimeout(() => {
const isLoaded = child && child.complete && child.naturalHeight !== 0; const isLoaded = child && child.complete && child.naturalHeight !== 0;
console.log(isLoaded, child.getAttribute("src"));
if (child && !isLoaded) { if (child && !isLoaded) {
child.style.opacity = 0; child.style.opacity = 0;
child.addEventListener("load", () => { child.addEventListener("load", () => {
@ -254,4 +256,5 @@ document.querySelectorAll("[data-thumb]").forEach((entry) => {
child.style.opacity = 1; child.style.opacity = 1;
}); });
} }
}, 50);
}); });