mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 03:26:16 +00:00
Use Picture element to automatically choose webp
Remove loadOnView function as has to be remade for new picture element Remove broken way of checking for Webp support
This commit is contained in:
parent
16df5bc255
commit
2cf7bc9091
10 changed files with 119 additions and 124 deletions
|
@ -5,26 +5,8 @@ function imgFade(obj, time = 200) {
|
|||
|
||||
setTimeout(() => { obj.style.animation = null; }, time);
|
||||
}
|
||||
// Lazy load images when they are in view
|
||||
function loadOnView() {
|
||||
const lazyLoad = document.querySelectorAll('#lazy-load');
|
||||
const webpSupport = checkWebpSupport();
|
||||
|
||||
for (let i = 0; i < lazyLoad.length; i++) {
|
||||
const image = lazyLoad[i];
|
||||
if (image.getBoundingClientRect().top < window.innerHeight && image.getBoundingClientRect().bottom > 0) {
|
||||
if (!image.src && webpSupport) {
|
||||
image.src = `${image.getAttribute('data-src')}&e=webp`;
|
||||
} else if (!image.src) {
|
||||
image.src = image.getAttribute('data-src');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
loadOnView();
|
||||
|
||||
const times = document.querySelectorAll('.time');
|
||||
for (let i = 0; i < times.length; i++) {
|
||||
// Remove milliseconds
|
||||
|
@ -70,8 +52,6 @@ window.onload = function () {
|
|||
}
|
||||
};
|
||||
window.onscroll = function () {
|
||||
loadOnView();
|
||||
|
||||
// Top Of Page button
|
||||
const topOfPage = document.querySelector('.top-of-page');
|
||||
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
|
||||
|
@ -90,6 +70,3 @@ window.onscroll = function () {
|
|||
}
|
||||
}
|
||||
};
|
||||
window.onresize = function () {
|
||||
loadOnView();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue