fix: check if image loaded

This commit is contained in:
max_richter 2023-11-20 16:43:36 +01:00
parent 788a7b7c8f
commit 06bcdae2d1
2 changed files with 4 additions and 0 deletions

View File

@ -28,4 +28,5 @@ img.lazy-image {
img.lazy-image.loaded { img.lazy-image.loaded {
opacity: 1; opacity: 1;
z-index:-1;
} }

View File

@ -5,6 +5,9 @@ window.onload = function(){
for (let i = 0; i < lazyImages.length; i++) { for (let i = 0; i < lazyImages.length; i++) {
var element = lazyImages[i]; var element = lazyImages[i];
element.classList.add("lazy-image") element.classList.add("lazy-image")
element.onload = function(){
element.classList.add("loaded");
}
element.addEventListener("load", function(){ element.addEventListener("load", function(){
element.classList.add("loaded"); element.classList.add("loaded");
}) })