fix: error when images load too fast

This commit is contained in:
max_richter 2023-08-11 17:25:19 +02:00
parent e666664924
commit 0f3f64d118

View File

@ -246,7 +246,8 @@ document.querySelectorAll("[data-thumb]").forEach((entry) => {
entry.style.backgroundSize = "cover";
const child = entry.querySelector("img[data-thumb-img]");
if (child && !child.complete) {
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";