Skip to content

Commit 6b6725d

Browse files
committed
feat(reader): scroll 3/4 viewport on PgDn/PgUp
Adds PageDown/PageUp scrolling to the reader's scroll container, sized at Math.round(clientHeight * 0.75) so the user keeps ~25% overlap with the previously visible content between presses (Vimium's d/u idiom). - Reader.svelte: extends the existing $effect keydown listener; preventDefault + stopImmediatePropagation so the browser's default page-scroll doesn't double-fire. - KeyboardHelp.svelte: documents PgDn/PgUp in the Reader section.
1 parent 64f34c6 commit 6b6725d

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/lib/components/KeyboardHelp.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
items: [
7171
{ keys: [['j'], ['k']], desc: 'Next / previous message' },
7272
{ keys: [['J'], ['K']], desc: 'Scroll down / up' },
73+
{ keys: [['PgDn'], ['PgUp']], desc: 'Scroll 3/4 page down / up' },
7374
{ keys: [['g', 'g']], desc: 'Scroll to top' },
7475
{ keys: [['G']], desc: 'Scroll to bottom' },
7576
{ keys: [['f']], desc: 'Follow link / attachment by hint' },

src/lib/components/Reader.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@
7070
e.preventDefault();
7171
e.stopImmediatePropagation();
7272
scrollEl.scrollBy({ top: (e.key === 'J' ? 1 : -1) * 20 * SCROLL_LINE_PX, behavior: 'smooth' });
73+
return;
74+
}
75+
if (e.key === 'PageDown' || e.key === 'PageUp') {
76+
e.preventDefault();
77+
e.stopImmediatePropagation();
78+
const step = Math.round(scrollEl.clientHeight * 0.75);
79+
scrollEl.scrollBy({ top: e.key === 'PageDown' ? step : -step, behavior: 'smooth' });
7380
}
7481
}
7582
window.addEventListener('keydown', onKeyDown);

0 commit comments

Comments
 (0)