grain.social is a photo sharing platform built on atproto. grain.social
atproto photography appview
57
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: restore mobile scroll position on back navigation

Use SvelteKit snapshots to capture and restore the .col-center
scroll position, fixing the issue where navigating back from a
profile returns to the top of the feed on mobile.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+14 -2
+14 -2
app/routes/+layout.svelte
··· 1 + <script lang="ts" module> 2 + import type { Snapshot } from './$types' 3 + 4 + export const snapshot: Snapshot<number> = { 5 + capture: () => document.querySelector('main.col-center')?.scrollTop ?? 0, 6 + restore: (y) => { 7 + requestAnimationFrame(() => { 8 + document.querySelector('main.col-center')?.scrollTo(0, y) 9 + }) 10 + }, 11 + } 12 + </script> 13 + 1 14 <script lang="ts"> 2 15 import type { Snippet } from 'svelte' 3 16 import '../app.css' ··· 8 21 import { loadPreferences } from '$lib/preferences' 9 22 import { afterNavigate } from '$app/navigation' 10 23 11 - // Safety net: clear any stale body overflow locks left by overlays (e.g. StoryViewer) 12 - // that were destroyed during navigation without proper cleanup 24 + // Clear stale body overflow locks left by overlays (e.g. StoryViewer) 13 25 afterNavigate(() => { 14 26 if (document.body.style.overflow === 'hidden') { 15 27 document.body.style.overflow = ''