From 6096a1af82ba7ffa671acb72a1a1a3624bb6dc55 Mon Sep 17 00:00:00 2001 From: rgoshen Date: Wed, 16 Oct 2024 16:47:10 -0700 Subject: [PATCH] fix scroll issue Signed-off-by: rgoshen --- index.html | 4 ++-- scripts/script.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index e00d106..d5cbf09 100644 --- a/index.html +++ b/index.html @@ -143,13 +143,13 @@

Rick Goshen

Software Engineer

My skills My portfolio { + button.addEventListener('click', function(e) { + console.log('clicked'); + e.preventDefault(); // Prevent the default anchor behavior + const targetId = e.currentTarget.getAttribute("href"); + const targetElement = document.querySelector(targetId); + const navbarHeight = document.querySelector('nav').offsetHeight; // Replace 'nav' with your navbar selector + + // Smooth scroll to the section, adjusted for the navbar height + window.scrollTo({ + top: targetElement.offsetTop - navbarHeight, + behavior: 'smooth' + }); + }); +}); \ No newline at end of file