mirror of
https://github.com/rhysd/Mstdn.git
synced 2025-01-21 20:52:11 +01:00
fix scrolling timeline view
This commit is contained in:
parent
02a406b821
commit
6cf895a13c
@ -6,13 +6,15 @@ import log from './log';
|
|||||||
import PluginsLoader from './plugins';
|
import PluginsLoader from './plugins';
|
||||||
import {Config, Account} from '../main/config';
|
import {Config, Account} from '../main/config';
|
||||||
|
|
||||||
function scrollable() {
|
function scrollable(pred: (elem: HTMLElement) => void) {
|
||||||
const scrollable = document.querySelector('.scrollable');
|
const scrollables = document.querySelectorAll('.scrollable') as NodeListOf<HTMLElement>;
|
||||||
if (!scrollable) {
|
if (scrollables.length === 0) {
|
||||||
log.error('Scrollable element was not found!');
|
log.error('Scrollable element was not found!');
|
||||||
return {scrollTop: 0};
|
return
|
||||||
|
}
|
||||||
|
for (const elem of scrollables) {
|
||||||
|
pred(elem);
|
||||||
}
|
}
|
||||||
return scrollable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function navigateTo(host: string, path: string) {
|
function navigateTo(host: string, path: string) {
|
||||||
@ -34,16 +36,16 @@ function navigateTo(host: string, path: string) {
|
|||||||
|
|
||||||
const ShortcutActions = {
|
const ShortcutActions = {
|
||||||
'scroll-top': () => {
|
'scroll-top': () => {
|
||||||
scrollable().scrollTop = 0;
|
scrollable(s => { s.scrollTop = 0; });
|
||||||
},
|
},
|
||||||
'scroll-bottom': () => {
|
'scroll-bottom': () => {
|
||||||
scrollable().scrollTop = document.body.scrollHeight;
|
scrollable(s => { s.scrollTop = document.body.scrollHeight; });
|
||||||
},
|
},
|
||||||
'scroll-down': () => {
|
'scroll-down': () => {
|
||||||
scrollable().scrollTop += window.innerHeight / 3;
|
scrollable(s => { s.scrollTop += window.innerHeight / 3; });
|
||||||
},
|
},
|
||||||
'scroll-up': () => {
|
'scroll-up': () => {
|
||||||
scrollable().scrollTop -= window.innerHeight / 3;
|
scrollable(s => { s.scrollTop -= window.innerHeight / 3; });
|
||||||
},
|
},
|
||||||
'next-account': () => {
|
'next-account': () => {
|
||||||
Ipc.send('mstdn:next-account');
|
Ipc.send('mstdn:next-account');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user