git.ntnlv.ca
Repositories
Help
Report an Issue
lbd.git
Code
Commits
Branches
Tags
Search
Tree:
bd6b8bc
Branches
Tags
prod
lbd.git
wp-content
themes
rookie
js
scripts.js
sticky menu implementation
davvalent
commited
bd6b8bc
at 2024-05-18 04:33:13
scripts.js
Blame
History
Raw
/** * scripts.js * * Custom scripts for the Rookie theme. */ ( function( $ ) { $('.comment-metadata time').timeago(); } )( jQuery ); // sticky menu // When the user scrolls the page, execute myFunction window.onscroll = function() {myFunction()}; // Get the navbar let navbar = document.getElementById("site-navigation"), header = document.getElementById("masthead"), width = document.getElementById("sliding-bar"); // Get the offset position of the navbar let sticky = 170; // Add the sticky class to the navbar when you reach its scroll position. Remove "sticky" when you leave the scroll position function myFunction() { if (window.scrollY >= sticky) { navbar.classList.add("sticky-nav-bar"); header.classList.add("sticky-container"); width.classList.add("width"); } else { navbar.classList.remove("sticky-nav-bar"); header.classList.remove("sticky-container"); width.classList.remove("width"); } }