aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/resources/js/sticky.js
blob: 9fc0a2656a19f7ce959eab5e0023a09f09e23a19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// When the user scrolls the page, execute myFunction
window.onscroll = function() {myFunction()};

// Get the header
var header = document.getElementById("menubar");

// Get the offset position of the navbar
var sticky = header.offsetTop/* + 20*/;

// Add the sticky class to the header when you reach its scroll position. Remove "sticky" when you leave the scroll position
function myFunction() {
  if (window.pageYOffset > sticky) {
    header.classList.add("sticky");
  } else {
    header.classList.remove("sticky");
  }
}