Initial commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
// open
|
||||
const burger = document.querySelectorAll(".navbar-burger");
|
||||
const menu = document.querySelectorAll(".navbar-menu");
|
||||
|
||||
if (burger.length && menu.length) {
|
||||
for (var i = 0; i < burger.length; i++) {
|
||||
burger[i].addEventListener("click", function () {
|
||||
for (var j = 0; j < menu.length; j++) {
|
||||
menu[j].classList.toggle("hidden");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// close
|
||||
const close = document.querySelectorAll(".navbar-close");
|
||||
const backdrop = document.querySelectorAll(".navbar-backdrop");
|
||||
|
||||
if (close.length) {
|
||||
for (var i = 0; i < close.length; i++) {
|
||||
close[i].addEventListener("click", function () {
|
||||
for (var j = 0; j < menu.length; j++) {
|
||||
menu[j].classList.toggle("hidden");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (backdrop.length) {
|
||||
for (var i = 0; i < backdrop.length; i++) {
|
||||
backdrop[i].addEventListener("click", function () {
|
||||
for (var j = 0; j < menu.length; j++) {
|
||||
menu[j].classList.toggle("hidden");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
var toTopButton = document.getElementById("to-top-button");
|
||||
|
||||
// When the user scrolls down 200px from the top of the document, show the button
|
||||
window.onscroll = function () {
|
||||
if (
|
||||
document.body.scrollTop > 250 ||
|
||||
document.documentElement.scrollTop > 250
|
||||
) {
|
||||
toTopButton.classList.remove("hidden");
|
||||
} else {
|
||||
toTopButton.classList.add("hidden");
|
||||
}
|
||||
};
|
||||
|
||||
// When the user clicks on the button, scroll to the top of the document
|
||||
function goToTop() {
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
}
|
||||
Reference in New Issue
Block a user