Skip to content

Commit

Permalink
Removed some scroll handling code, will try again in another life
Browse files Browse the repository at this point in the history
  • Loading branch information
milkcee12 committed Feb 21, 2024
1 parent b729e39 commit 6fb2b63
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 22 deletions.
4 changes: 4 additions & 0 deletions src/MDLayout.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<script lang="ts">
import "$lib/scss/markdown.scss";
</script>

<div class="markdown">
<slot />
</div>
Expand Down
2 changes: 0 additions & 2 deletions src/lib/data/md/last-broadcast.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ tags:
---

<script lang="ts">
import "$lib/scss/markdown.scss";

import ColorLink from "$lib/components/common/ColorLink.svelte";

import banner from "$lib/images/md-assets/last-broadcast/banner.png";
Expand Down
2 changes: 0 additions & 2 deletions src/lib/data/md/re-store.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ tags:
---

<script lang="ts">
import "$lib/scss/markdown.scss";

import ColorLink from "$lib/components/common/ColorLink.svelte";

import banner from "$lib/images/md-assets/re-store/banner.png";
Expand Down
9 changes: 5 additions & 4 deletions src/lib/data/yml/archive.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# next_id: 3
projects:
- id: 1
title: Re:STORE
date: 2021
slug: /archive/re-store
- id: 2
title: Last Broadcast
date: 2023
slug: /archive/last-broadcast
- id: 1
title: Re:STORE
date: 2021
slug: /archive/re-store

4 changes: 4 additions & 0 deletions src/routes/(app)/archive/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
}
}
.breadcrumbs a, .footer a {
text-decoration: none;
}
.footer {
margin-top: 6em;
}
Expand Down
19 changes: 5 additions & 14 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,20 @@
import Footer from "$lib/components/common/Footer.svelte";
import { Modals, closeModal } from "svelte-modals";
import { fade } from "svelte/transition";
import { page } from "$app/stores";
import type { Snapshot } from "./$types";
import { afterNavigate, disableScrollHandling } from "$app/navigation";
import { disableScrollHandling, onNavigate } from "$app/navigation";
$: pathname = $page.url.pathname;
// Allows you to preserve scroll position on back button while keeping smooth page transition behavior
let scrollYState: number;
export const snapshot: Snapshot<number> = {
capture: () => window.scrollY,
restore: (value) => (scrollYState = value),
};
export let data;
// Allows page transition without snapping scroll back to top
afterNavigate(() => {
onNavigate(() => {
disableScrollHandling();
setTimeout(() => {
scrollTo({ top: scrollYState ?? 0, behavior: "instant" });
scrollTo({ top: 0, behavior: "instant" });
}, 300);
});
</script>

{#key pathname}
{#key data.pathname}
<div in:fade={{ duration: 300, delay: 400 }} out:fade={{ duration: 300 }}>
<div class="mobile-wrapper">
<slot />
Expand Down
8 changes: 8 additions & 0 deletions src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
export const prerender = true;

export const load = ({ url }) => {
const { pathname } = url;

return {
pathname,
};
};

0 comments on commit 6fb2b63

Please sign in to comment.