play around with image loading
This commit is contained in:
parent
d4db8430e4
commit
d2a02fcf34
@ -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);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user