article scroll keybindings

This commit is contained in:
Nazar Kanaev 2021-03-16 00:01:53 +00:00
parent e7fa98008d
commit 721de3fba6
2 changed files with 26 additions and 2 deletions

View File

@ -390,8 +390,8 @@
<table class="table table-borderless table-sm table-compact m-0">
<tr>
<td>
<kbd>1</kbd> /
<kbd>2</kbd> /
<kbd>1</kbd>
<kbd>2</kbd>
<kbd>3</kbd>
</td>
<td>show unread / starred / all feeds</td>
@ -436,6 +436,13 @@
<td><kbd>o</kbd></td>
<td>open an article's link</td>
</tr>
<tr>
<td>
<kbd>f</kbd>
<kbd>b</kbd>
</td>
<td>scroll an article forward / backward</td>
</tr>
</table>
</div>
</div>

View File

@ -73,6 +73,15 @@ var helperFunctions = {
if (target && scroll) scrollto(target, scroll)
})
},
scrollContent: function(direction) {
var padding = 40
var scroll = document.querySelector('.content')
if (!scroll) return
var height = scroll.getBoundingClientRect().height
scroll.scrollTop += (height - padding) * direction
}
}
var shortcutFunctions = {
@ -112,6 +121,12 @@ var shortcutFunctions = {
previousFeed() {
helperFunctions.navigateToFeed(-1)
},
scrollForward: function() {
helperFunctions.scrollContent(+1)
},
scrollBackward: function() {
helperFunctions.scrollContent(-1)
},
showAll() {
vm.filterSelected = ''
},
@ -134,6 +149,8 @@ var keybindings = {
"k": shortcutFunctions.previousItem,
"l": shortcutFunctions.nextFeed,
"h": shortcutFunctions.previousFeed,
"f": shortcutFunctions.scrollForward,
"b": shortcutFunctions.scrollBackward,
"1": shortcutFunctions.showUnread,
"2": shortcutFunctions.showStarred,
"3": shortcutFunctions.showAll,