Homepage/res/header.js
caskd 31e35bd611 Added functionality
Added jQuery for performance improvement
Moved DOM elements by priority
Moved header below banner
Swapped sides for easier css adapting
2018-06-13 17:36:29 +02:00

16 lines
468 B
JavaScript

window.onscroll = function() {checkheader()};
// Get the header
var header = document.getElementById("myHeader");
// Get the offset position of the navbar
var sticky = header.offsetTop;
// Add the sticky class to the header when you reach its scroll position. Remove "sticky" when you leave the scroll position
function checkheader() {
if (window.pageYOffset >= sticky) {
header.classList.add("sticky");
} else {
header.classList.remove("sticky");
}
}