Basic navbar

not my best work, o well...
This commit is contained in:
2021-12-21 20:08:40 +01:00
parent 49b691132a
commit 0244ed417d
42 changed files with 8847 additions and 5 deletions

43
_CDN/js/script.js Normal file
View File

@@ -0,0 +1,43 @@
/* const nav = document.querySelector('#nav');
let navTop = navbar.offsetTop;
function fixedNav() {
if (window.scrollY >= navTop) {
navbar.classList.add('sticky');
} else {
navbar.classList.remove('sticky');
}
}
window.addEventListener('scroll', fixedNav);
*/
/* ===============================================
Hide navbar on scrolldown, show on scrollup.
=============================================== */
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("navbar").style.top = "0";
} else {
document.getElementById("navbar").style.top = "-52px";
}
prevScrollpos = currentScrollPos;
}
/* ===============================================
Drop list on click, dropdownbtn (cur. links).
=============================================== */
function DropFunc() {
document.getElementById("DropList").classList.toggle("show");
}
window.onclick = function(e) {
if (!e.target.matches('.dropbtn')) {
var DropList = document.getElementById("DropList");
if (DropList.classList.contains('show')) {
DropList.classList.remove('show');
}
}
}