mirror of
https://github.com/zen-browser/www.git
synced 2025-07-08 17:30:01 +02:00
chore(layout): prevent page navigation if same page
This commit is contained in:
parent
942a73d53c
commit
97e9ff35c8
1 changed files with 18 additions and 2 deletions
|
@ -32,7 +32,7 @@ import { ClientRouter } from 'astro:transitions'
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<html lang="en">
|
<html lang="en" transition:name="root" transition:animate="none">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta
|
<meta
|
||||||
|
@ -78,7 +78,9 @@ import { ClientRouter } from 'astro:transitions'
|
||||||
class="overflow-x-hidden bg-paper font-['bricolage-grotesque'] text-dark"
|
class="overflow-x-hidden bg-paper font-['bricolage-grotesque'] text-dark"
|
||||||
>
|
>
|
||||||
<NavBar />
|
<NavBar />
|
||||||
<slot />
|
<div transition:animate="slide" transition:name="page">
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
<Footer />
|
<Footer />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -141,3 +143,17 @@ import { ClientRouter } from 'astro:transitions'
|
||||||
vertical-align: -0.125em;
|
vertical-align: -0.125em;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.addEventListener('astro:page-load', () => {
|
||||||
|
document.querySelectorAll('a').forEach((link) => {
|
||||||
|
link.addEventListener('click', (e) => {
|
||||||
|
const href = link.getAttribute('href')
|
||||||
|
if (href && href === window.location.pathname) {
|
||||||
|
e.preventDefault()
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue