From 06bcdae2d1fb086989590e3e0d8aa1a72b8b3d4a Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 20 Nov 2023 16:43:36 +0100 Subject: [PATCH] fix: check if image loaded --- src/routes/global.css | 1 + static/lazy.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/routes/global.css b/src/routes/global.css index e5a49da..d8b5645 100644 --- a/src/routes/global.css +++ b/src/routes/global.css @@ -28,4 +28,5 @@ img.lazy-image { img.lazy-image.loaded { opacity: 1; + z-index:-1; } diff --git a/static/lazy.js b/static/lazy.js index 56464a3..9f008c2 100644 --- a/static/lazy.js +++ b/static/lazy.js @@ -5,6 +5,9 @@ window.onload = function(){ for (let i = 0; i < lazyImages.length; i++) { var element = lazyImages[i]; element.classList.add("lazy-image") + element.onload = function(){ + element.classList.add("loaded"); + } element.addEventListener("load", function(){ element.classList.add("loaded"); })