fix: check if image loaded
This commit is contained in:
parent
788a7b7c8f
commit
06bcdae2d1
@ -28,4 +28,5 @@ img.lazy-image {
|
|||||||
|
|
||||||
img.lazy-image.loaded {
|
img.lazy-image.loaded {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
z-index:-1;
|
||||||
}
|
}
|
||||||
|
@ -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");
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user