mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 11:36:16 +00:00
Move JavaScript around because I want to!
This commit is contained in:
parent
6bee5a7113
commit
4622cc29c5
7 changed files with 19 additions and 18 deletions
|
@ -1,19 +1,12 @@
|
|||
let webpSupport = false;
|
||||
try {
|
||||
new Image().src = 'data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAwA0JaQAA3AA/vuUAAA=';
|
||||
webpSupport = true;
|
||||
} catch (e) {
|
||||
webpSupport = false;
|
||||
}
|
||||
|
||||
// fade in images
|
||||
function imgFade(obj, time = 250) {
|
||||
async function imgFade(obj, time = 250) {
|
||||
obj.style.transition = `opacity ${time}ms`;
|
||||
obj.style.opacity = 1;
|
||||
}
|
||||
// Lazy load images when they are in view
|
||||
function loadOnView() {
|
||||
async function loadOnView() {
|
||||
const lazyLoad = document.querySelectorAll('#lazy-load');
|
||||
const webpSupport = checkWebpSupport();
|
||||
|
||||
for (let i = 0; i < lazyLoad.length; i++) {
|
||||
let image = lazyLoad[i];
|
|
@ -61,5 +61,3 @@ function addNotification(notificationText, notificationLevel) {
|
|||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// uwu
|
10
gallery/static/lib/webp.js
Normal file
10
gallery/static/lib/webp.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
async function checkWebpSupport() {
|
||||
var webpSupport = false;
|
||||
try {
|
||||
webpSupport = document.createElement('canvas').toDataURL('image/webp').indexOf('data:image/webp') == 0;
|
||||
} catch (e) {
|
||||
webpSupport = false;
|
||||
}
|
||||
|
||||
return webpSupport;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue