Update SectionScroll behavior

This commit is contained in:
dertyp7
2024-01-14 13:09:03 +01:00
parent 160aa55fac
commit 0de5c8d60d
2 changed files with 2 additions and 6 deletions

View File

@@ -68,7 +68,7 @@ export default function App() {
</div> </div>
<h4>Website under construction 🚧👷</h4> <h4>Website under construction 🚧👷</h4>
<SectionScroll sections={["about", "skills", "projects"]} /> <SectionScroll sections={["", "skills", "projects"]} />
</div> </div>
); );
} }

View File

@@ -25,11 +25,7 @@ export default function SectionScroll({ sections }: { sections: string[] }) {
if (newIndex < 0) newIndex = sections.length - 1; if (newIndex < 0) newIndex = sections.length - 1;
if (newIndex >= sections.length) newIndex = 0; if (newIndex >= sections.length) newIndex = 0;
const sectionElement = document.getElementById(sections[newIndex]); window.location.hash = sections[newIndex];
if (sectionElement) {
sectionElement.scrollIntoView({ behavior: "smooth" });
}
setCurrentSectionIndex(newIndex); setCurrentSectionIndex(newIndex);
} }