Homepage/res/header.js

18 lines
558 B
JavaScript
Raw Normal View History

window.onscroll = function() {checkheader()};
2018-06-14 07:39:18 +00:00
window.onload = function() {checkheader()};
// Get the header
2018-06-13 17:12:17 +00:00
var header = document.getElementById("pgHeader");
var banner = document.getElementById("text");
// Get the offset position of the navbar
2018-06-13 17:12:17 +00:00
var sticky = banner.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");
}
}