fix: lazy load portraits
This commit is contained in:
parent
df3afc90a7
commit
871c6d6959
@ -1,19 +1,16 @@
|
||||
window.onload = function () {
|
||||
window.onload = function () {
|
||||
// Get all <img> elements with loading="lazy"
|
||||
var lazyImages = document.querySelectorAll('img[loading="lazy"]');
|
||||
|
||||
console.log(lazyImages)
|
||||
|
||||
// Loop through each image and apply the fade-in effect
|
||||
lazyImages.forEach(function (lazyImage) {
|
||||
lazyImage.style.opacity = 0;
|
||||
lazyImage.classList.add("lazy-image")
|
||||
console.log(lazyImage)
|
||||
|
||||
// Create an image element to check when it's loaded
|
||||
var img = new Image();
|
||||
img.src = lazyImage.src;
|
||||
img.onload = function () {
|
||||
console.log("lloooaded")
|
||||
lazyImage.style.opacity = 1;
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user