Github CI lint - phpcbf

This commit is contained in:
github-actions 2020-02-15 23:11:35 +00:00
parent 14600612bb
commit 0f5208ef18

View file

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