Github CI lint - phpcbf

This commit is contained in:
github-actions 2020-02-15 23:05:56 +00:00
parent 6985bf6f10
commit 333385feb5
3 changed files with 75 additions and 75 deletions

View file

@ -2,55 +2,55 @@
* Scroll up Header
* Modified from https://codepen.io/sajjad/pen/vgEZNy
*/
(function() {
// Hide header on scroll down
var didScroll,
lastScrollTop = 0,
navbarHeight = 0;
var delta = 0,
header = document.getElementsByTagName('header')[0],
headerContainer = document.querySelector('.mw-header-container');
// Hide header on scroll down
var didScroll,
lastScrollTop = 0,
navbarHeight = 0;
var delta = 0,
header = document.getElementsByTagName('header')[0],
headerContainer = document.querySelector('.mw-header-container');
if (headerContainer !== null) {
navbarHeight = headerContainer.offsetHeight;
}
if (headerContainer !== null) {
navbarHeight = headerContainer.offsetHeight;
}
window.addEventListener('scroll', function() {
didScroll = true;
});
window.addEventListener('scroll', function() {
didScroll = true;
});
function hasScrolled() {
var st = window.scrollY; // Make scroll more than delta
function hasScrolled() {
var st = window.scrollY; // Make scroll more than delta
if (Math.abs(lastScrollTop - st) <= delta) {
return;
}
if (Math.abs(lastScrollTop - st) <= delta) {
return;
}
if (st > lastScrollTop && st > navbarHeight) {
// If scrolled down and past the navbar, add class .nav-up.
// Scroll Down
header.classList.remove('nav-down');
header.classList.add('nav-up');
} else {
// Scroll Up
var body = document.body,
html = document.documentElement,
documentHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
if (st > lastScrollTop && st > navbarHeight) {
// If scrolled down and past the navbar, add class .nav-up.
// Scroll Down
header.classList.remove('nav-down');
header.classList.add('nav-up');
} else {
// Scroll Up
var body = document.body,
html = document.documentElement,
documentHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
if (st + window.innerHeight < documentHeight) {
header.classList.remove('nav-up');
header.classList.add('nav-down');
}
}
if (st + window.innerHeight < documentHeight) {
header.classList.remove('nav-up');
header.classList.add('nav-down');
}
}
lastScrollTop = st;
}
lastScrollTop = st;
}
setInterval(function() {
if (didScroll) {
hasScrolled();
didScroll = false;
}
}, 250);
setInterval(function() {
if (didScroll) {
hasScrolled();
didScroll = false;
}
}, 250);
})();

View file

@ -4,41 +4,41 @@
*
* Lazyloading images with Native API or IntersectionObserver
*/
// Native API
if ('loading' in HTMLImageElement.prototype) {
document.querySelectorAll('img.lazy').forEach(function(img) {
img.setAttribute('src', img.getAttribute('data-src'));
document.querySelectorAll('img.lazy').forEach(function(img) {
img.setAttribute('src', img.getAttribute('data-src'));
if (img.hasAttribute('data-srcset')) {
img.setAttribute('srcset', img.getAttribute('data-srcset'));
}
if (img.hasAttribute('data-srcset')) {
img.setAttribute('srcset', img.getAttribute('data-srcset'));
}
img.classList.remove('lazy');
});
img.classList.remove('lazy');
});
} else {
// IntersectionObserver API
if (typeof IntersectionObserver !== 'undefined' && 'forEach' in NodeList.prototype) {
var observer = new IntersectionObserver(function(changes) {
if ('connection' in navigator && navigator.connection.saveData === true) {
return;
}
// IntersectionObserver API
if (typeof IntersectionObserver !== 'undefined' && 'forEach' in NodeList.prototype) {
var observer = new IntersectionObserver(function(changes) {
if ('connection' in navigator && navigator.connection.saveData === true) {
return;
}
changes.forEach(function(change) {
if (change.isIntersecting) {
change.target.setAttribute('src', change.target.getAttribute('data-src'));
changes.forEach(function(change) {
if (change.isIntersecting) {
change.target.setAttribute('src', change.target.getAttribute('data-src'));
if (change.target.hasAttribute('data-srcset')) {
change.target.setAttribute('srcset', change.target.getAttribute('data-srcset'));
}
if (change.target.hasAttribute('data-srcset')) {
change.target.setAttribute('srcset', change.target.getAttribute('data-srcset'));
}
change.target.classList.remove('lazy');
observer.unobserve(change.target);
}
});
});
document.querySelectorAll('img.lazy').forEach(function(img) {
observer.observe(img);
});
}
change.target.classList.remove('lazy');
observer.unobserve(change.target);
}
});
});
document.querySelectorAll('img.lazy').forEach(function(img) {
observer.observe(img);
});
}
}

View file

@ -25,10 +25,10 @@ function SmoothScroll() {
}
function ScrollSpy() {
var sections = document.querySelectorAll(".mw-headline");
window.addEventListener("scroll", function() {
var scrollPos = document.documentElement.scrollTop || document.body.scrollTop,
section, id;
var sections = document.querySelectorAll(".mw-headline");
window.addEventListener("scroll", function() {
var scrollPos = document.documentElement.scrollTop || document.body.scrollTop,
section, id;
for (section in sections) {
if (