Skip to content

Commit

Permalink
script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
sp3ctr4l-h4ck3rs-gu1ld authored Sep 24, 2024
1 parent ececed6 commit 175a724
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,19 @@ document.addEventListener('DOMContentLoaded', function () {
var footer = document.querySelector('footer');
var lastScrollTop = 0;

function toggleNavMenu() {
var nav = document.getElementById('mainNav');
if (nav.style.display === 'block') {
nav.style.display = 'none';
} else {
nav.style.display = 'block';
}
}

function showSection(sectionId) {
sections.forEach(function (section) {
section.style.display = (section.id === sectionId) ? 'block' : 'none';
section.classList.remove('show');
if (section.id === sectionId) {
setTimeout(() => section.classList.add('show'), 100);
}
});
}

function handleNavClick(event) {
event.preventDefault();
var sectionId = event.target.getAttribute('href').substring(1);
showSection(sectionId);
toggleNavMenu();
}

function handleScroll() {
Expand All @@ -43,8 +36,9 @@ document.addEventListener('DOMContentLoaded', function () {
lastScrollTop = scrollPosition;
}

window.addEventListener('scroll', handleScroll);
showSection('Introducción');

window.addEventListener('scroll', handleScroll);
navLinks.forEach(function (link) {
link.addEventListener('click', handleNavClick);
});
Expand Down

0 comments on commit 175a724

Please sign in to comment.