scroll by pages
This commit is contained in:
parent
02c0cfd97d
commit
20e66ea2c7
4 changed files with 19 additions and 1 deletions
|
@ -7,6 +7,12 @@ const DEFAULT_KEYMAP = [
|
||||||
{ keys: [{ code: KeyboardEvent.DOM_VK_O, shift: true }], action: [ actions.CMD_TABS_OPEN, true ]},
|
{ keys: [{ code: KeyboardEvent.DOM_VK_O, shift: true }], action: [ actions.CMD_TABS_OPEN, true ]},
|
||||||
{ keys: [{ code: KeyboardEvent.DOM_VK_K }], action: [ actions.SCROLL_LINES, -1 ]},
|
{ keys: [{ code: KeyboardEvent.DOM_VK_K }], action: [ actions.SCROLL_LINES, -1 ]},
|
||||||
{ keys: [{ code: KeyboardEvent.DOM_VK_J }], action: [ actions.SCROLL_LINES, 1 ]},
|
{ keys: [{ code: KeyboardEvent.DOM_VK_J }], action: [ actions.SCROLL_LINES, 1 ]},
|
||||||
|
{ keys: [{ code: KeyboardEvent.DOM_VK_E, ctrl: true }], action: [ actions.SCROLL_LINES, -1 ]},
|
||||||
|
{ keys: [{ code: KeyboardEvent.DOM_VK_Y, ctrl: true }], action: [ actions.SCROLL_LINES, 1 ]},
|
||||||
|
{ keys: [{ code: KeyboardEvent.DOM_VK_U, ctrl: true }], action: [ actions.SCROLL_PAGES, -0.5 ]},
|
||||||
|
{ keys: [{ code: KeyboardEvent.DOM_VK_D, ctrl: true }], action: [ actions.SCROLL_PAGES, 0.5 ]},
|
||||||
|
{ keys: [{ code: KeyboardEvent.DOM_VK_B, ctrl: true }], action: [ actions.SCROLL_PAGES, -1 ]},
|
||||||
|
{ keys: [{ code: KeyboardEvent.DOM_VK_F, ctrl: true }], action: [ actions.SCROLL_PAGES, 1 ]},
|
||||||
{ keys: [{ code: KeyboardEvent.DOM_VK_G }, { code: KeyboardEvent.DOM_VK_G }], action: [ actions.SCROLL_TOP ]},
|
{ keys: [{ code: KeyboardEvent.DOM_VK_G }, { code: KeyboardEvent.DOM_VK_G }], action: [ actions.SCROLL_TOP ]},
|
||||||
{ keys: [{ code: KeyboardEvent.DOM_VK_G, shift: true }], action: [ actions.SCROLL_BOTTOM ]},
|
{ keys: [{ code: KeyboardEvent.DOM_VK_G, shift: true }], action: [ actions.SCROLL_BOTTOM ]},
|
||||||
{ keys: [{ code: KeyboardEvent.DOM_VK_D }], action: [ actions.TABS_CLOSE ]},
|
{ keys: [{ code: KeyboardEvent.DOM_VK_D }], action: [ actions.TABS_CLOSE ]},
|
||||||
|
|
|
@ -45,6 +45,9 @@ const invokeEvent = (action) => {
|
||||||
case actions.SCROLL_LINES:
|
case actions.SCROLL_LINES:
|
||||||
scrolls.scrollLines(window, action[1]);
|
scrolls.scrollLines(window, action[1]);
|
||||||
break;
|
break;
|
||||||
|
case actions.SCROLL_PAGES:
|
||||||
|
scrolls.scrollPages(window, action[1]);
|
||||||
|
break;
|
||||||
case actions.SCROLL_TOP:
|
case actions.SCROLL_TOP:
|
||||||
scrolls.scrollTop(window, action[1]);
|
scrolls.scrollTop(window, action[1]);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -6,6 +6,13 @@ const scrollLines = (page, count) => {
|
||||||
page.scrollTo(x, y);
|
page.scrollTo(x, y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const scrollPages = (page, count) => {
|
||||||
|
let height = page.innerHeight;
|
||||||
|
let x = page.scrollX;
|
||||||
|
let y = page.scrollY + height * count;
|
||||||
|
page.scrollTo(x, y);
|
||||||
|
};
|
||||||
|
|
||||||
const scrollTop = (page) => {
|
const scrollTop = (page) => {
|
||||||
let x = page.scrollX;
|
let x = page.scrollX;
|
||||||
let y = 0;
|
let y = 0;
|
||||||
|
@ -18,4 +25,4 @@ const scrollBottom = (page) => {
|
||||||
page.scrollTo(x, y);
|
page.scrollTo(x, y);
|
||||||
};
|
};
|
||||||
|
|
||||||
export { scrollLines, scrollTop, scrollBottom }
|
export { scrollLines, scrollPages, scrollTop, scrollBottom }
|
||||||
|
|
|
@ -6,6 +6,7 @@ export const TABS_PREV = 'tabs.prev';
|
||||||
export const TABS_NEXT = 'tabs.next';
|
export const TABS_NEXT = 'tabs.next';
|
||||||
export const TABS_RELOAD = 'tabs.reload';
|
export const TABS_RELOAD = 'tabs.reload';
|
||||||
export const SCROLL_LINES = 'scroll.lines';
|
export const SCROLL_LINES = 'scroll.lines';
|
||||||
|
export const SCROLL_PAGES = 'scroll.pages';
|
||||||
export const SCROLL_TOP = 'scroll.top';
|
export const SCROLL_TOP = 'scroll.top';
|
||||||
export const SCROLL_BOTTOM = 'scroll.bottom';
|
export const SCROLL_BOTTOM = 'scroll.bottom';
|
||||||
export const FOLLOW_START = 'follow.start';
|
export const FOLLOW_START = 'follow.start';
|
||||||
|
@ -30,6 +31,7 @@ const CONTENT_ACTION_SET = new Set([
|
||||||
CMD_OPEN,
|
CMD_OPEN,
|
||||||
CMD_TABS_OPEN,
|
CMD_TABS_OPEN,
|
||||||
SCROLL_LINES,
|
SCROLL_LINES,
|
||||||
|
SCROLL_PAGES,
|
||||||
SCROLL_TOP,
|
SCROLL_TOP,
|
||||||
SCROLL_BOTTOM,
|
SCROLL_BOTTOM,
|
||||||
FOLLOW_START,
|
FOLLOW_START,
|
||||||
|
|
Reference in a new issue