feat: add scroll reset on navigation
This commit is contained in:
@@ -79,7 +79,7 @@ const normalizeTitle = !title ? global.name : `${title} | ${global.name}`;
|
|||||||
<Header />
|
<Header />
|
||||||
|
|
||||||
<!-- Main body -->
|
<!-- Main body -->
|
||||||
<div class="mask-container w-screen h-screen overflow-y-auto overflow-x-hidden">
|
<div id="reset-scroll" class="mask-container w-screen h-screen overflow-y-auto overflow-x-hidden">
|
||||||
<main>
|
<main>
|
||||||
|
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
@@ -96,6 +96,17 @@ const normalizeTitle = !title ? global.name : `${title} | ${global.name}`;
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const resetScroll = () => {
|
||||||
|
const scrollContainer = document.getElementById('reset-scroll');
|
||||||
|
if (scrollContainer) {
|
||||||
|
scrollContainer.scrollTop = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
resetScroll();
|
||||||
|
document.addEventListener('astro:after-swap', resetScroll);
|
||||||
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* Fade away content below header when scrolling */
|
/* Fade away content below header when scrolling */
|
||||||
.mask-container {
|
.mask-container {
|
||||||
|
|||||||
Reference in New Issue
Block a user