Skip to content

Commit

Permalink
πŸ› don't prevent external links from opening with .smooth-scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
krmax44 committed May 27, 2024
1 parent 454554e commit 9bf2326
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions frontend/javascript/smooth-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ const anchors: NodeListOf<HTMLAnchorElement> =
document.querySelectorAll('a.smooth-scroll')
anchors.forEach((element) => {
element.addEventListener('click', (event) => {
const a = event.target as HTMLAnchorElement
if (
a.host !== window.location.host ||
a.pathname !== window.location.pathname
)
return
event.preventDefault()

const { hash, href } = element
Expand Down

0 comments on commit 9bf2326

Please sign in to comment.