Move header up and disable hiding

This commit is contained in:
Vojtěch Káně
2021-06-01 17:32:06 +02:00
parent fc2dea0436
commit bcb0b3e9e4
4 changed files with 7 additions and 53 deletions

View File

@@ -1,21 +1,3 @@
/**
* Utils
*/
// Throttle
//
const throttle = (callback, limit) => {
let timeoutHandler = null;
return () => {
if (timeoutHandler == null) {
timeoutHandler = setTimeout(() => {
callback();
timeoutHandler = null;
}, limit);
}
};
};
// addEventListener Helper
//
const listen = (ele, e, callback) => {
@@ -24,26 +6,7 @@ const listen = (ele, e, callback) => {
}
}
/**
* Functions
*/
// Auto Hide Header
//
let header = document.getElementById('site-header');
let lastScrollPosition = window.pageYOffset;
const autoHideHeader = () => {
let currentScrollPosition = Math.max(window.pageYOffset, 0);
if (currentScrollPosition > lastScrollPosition) {
header.classList.remove('slideInUp');
header.classList.add('slideOutDown');
} else {
header.classList.remove('slideOutDown');
header.classList.add('slideInUp');
}
lastScrollPosition = currentScrollPosition;
}
// Mobile Menu Toggle
//
@@ -91,12 +54,4 @@ if (header !== null) {
window.location.hash = '#' + ele.id;
});
});
window.addEventListener('scroll', throttle(() => {
autoHideHeader();
if (mobileMenuVisible == true) {
toggleMobileMenu();
}
}, 250));
}