caskd
31e35bd611
Added jQuery for performance improvement Moved DOM elements by priority Moved header below banner Swapped sides for easier css adapting
16 lines
468 B
JavaScript
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");
|
|
}
|
|
} |