mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 11:36:16 +00:00
Fix lazyLoading script
This commit is contained in:
parent
a83930e377
commit
bf8142623e
5 changed files with 6 additions and 8 deletions
|
@ -5,14 +5,12 @@ function imgFade(obj, time = 250) {
|
|||
}
|
||||
// Lazy load images when they are in view
|
||||
function loadOnView() {
|
||||
let lazyLoad = document.querySelectorAll('#lazy-load');
|
||||
const lazyLoad = document.querySelectorAll('#lazy-load');
|
||||
|
||||
for (let i = 0; i < lazyLoad.length; i++) {
|
||||
let image = lazyLoad[i];
|
||||
if (image.getBoundingClientRect().top < window.innerHeight && image.getBoundingClientRect().bottom > 0) {
|
||||
if (!image.src) {
|
||||
image.src = `/api/file/${image.getAttribute('data-src')}?r=thumb` // e=webp
|
||||
}
|
||||
if (!image.src) { image.src = image.getAttribute('data-src') }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue