Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
nogueirawelton authored Aug 10, 2021
1 parent 5f651ad commit 3af790e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const scrollSections = document.querySelectorAll(".scroll");
const halfWindow = window.innerHeight * 0.5;
const activeItem = "active";

function scrollAnimation() {
scrollSections.forEach((section) => {
const sectionTop = section.getBoundingClientRect().top;
const isSectionVisible = sectionTop - halfWindow < 0;

if (isSectionVisible) {
section.classList.add("active");
section.classList.add(activeItem);
} else {
section.classList.remove("active");
section.classList.remove(activeItem);
}
});
}
Expand All @@ -20,11 +21,12 @@ function toggleMenu() {
const menu = document.querySelector(".header-nav-menu");
const links = document.querySelectorAll(".header-nav-menu li a");

openMenu.classList.toggle("active");
menu.classList.toggle("active");
openMenu.classList.toggle(activeItem);
menu.classList.toggle(activeItem);
links.forEach((link) => {
link.addEventListener("click", () => {
menu.classList.remove("active");
menu.classList.remove(activeItem);
openMenu.classList.remove(activeItem);
});
});
}
Expand Down

0 comments on commit 3af790e

Please sign in to comment.