Skip to content

Commit

Permalink
Agregar clase 'nav-link' a los enlaces de navegación
Browse files Browse the repository at this point in the history
  • Loading branch information
LucianoTreachi committed Dec 24, 2024
1 parent db292b1 commit 815b3e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@
</path>
</svg>
</button>
<!-- Links -->
<a href="#header">Inicio</a>
<a href="#contact">Contacto</a>
<a href="#about">Sobre Mí</a>
<a href="#skills">Habilidades</a>
<a href="#experience">Experiencia</a>
<a href="#education">Educación</a>
<!-- Navigation Links -->
<a href="#header" class="nav-link">Inicio</a>
<a href="#contact" class="nav-link">Contacto</a>
<a href="#about" class="nav-link">Sobre Mí</a>
<a href="#skills" class="nav-link">Habilidades</a>
<a href="#experience" class="nav-link">Experiencia</a>
<a href="#education" class="nav-link">Educación</a>
<!-- Theme Button -->
<button class="theme-button" aria-label="Modo de visualización: Claro/Oscuro">
<i class="ri-moon-fill"></i>
Expand Down
14 changes: 7 additions & 7 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const openMenuButton = document.querySelector(".open-menu-button");
const closeMenuButton = document.querySelector(".close-menu-button");
const navbar = document.querySelector(".navbar");
const links = document.querySelectorAll(".navbar a")
const navLinks = document.querySelectorAll(".nav-link")
const overlay = document.querySelector(".overlay");
const sections = document.querySelectorAll('section')
const scrollToTopLink = document.querySelector(".scroll-to-top-link");
Expand Down Expand Up @@ -108,7 +108,7 @@ document.body.addEventListener("keydown", (event) => {
});

// Navigation links
links.forEach((link) => {
navLinks.forEach((link) => {
link.addEventListener("click", (event) => {
const sectionId = link.getAttribute("href");
navigateToSection(event, sectionId);
Expand All @@ -117,15 +117,15 @@ links.forEach((link) => {


////////// ACTIVE LINK WITH SCROLL //////////
function activeLinks() {
function activeNavLinks() {
let len = sections.length;
while (--len && window.scrollY + 97 < sections[len].offsetTop) { }
links.forEach(link => link.classList.remove("active"));
links[len].classList.add("active");
navLinks.forEach(link => link.classList.remove("active"));
navLinks[len].classList.add("active");
}

activeLinks();
window.addEventListener("scroll", activeLinks);
activeNavLinks();
window.addEventListener("scroll", activeNavLinks);


////////// SCROLL TO TOP LINK //////////
Expand Down

0 comments on commit 815b3e1

Please sign in to comment.