Skip to content

Commit

Permalink
Tighten hash routing
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Dec 4, 2024
1 parent 7ed06b1 commit bd38f2a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/components/viewer/ViewerContext.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ layouts, stories, and tests.
$: noteMatchingPageHash = (note: Note) =>
note.id === noteFromHash($pageStore.url.hash);
$: console.log(`Page ${$currentPage}`);
function scrollToHash(hash?: string) {
const page: Nullable<number> = hash ? pageFromHash(hash) : null;
let el: Maybe<Nullable<HTMLElement>>;
Expand Down Expand Up @@ -189,7 +191,7 @@ layouts, stories, and tests.
}
$currentMode = mode;
$currentNote = $currentDoc.notes?.find(noteMatchingPageHash) ?? null;
if (shouldPaginate(mode) && $currentPage !== hashPage) {
if (shouldPaginate(mode) && (hashPage || 0) > 1) {
scrollToHash(hash);
}
});
Expand Down

0 comments on commit bd38f2a

Please sign in to comment.