scroll lines action

jh-changes
Shin'ya Ueoka 7 years ago
parent 6213f55e22
commit 02c0cfd97d
  1. 4
      src/background/key-queue.js
  2. 7
      src/content/index.js
  3. 10
      src/content/scrolls.js
  4. 6
      src/shared/actions.js

@ -5,8 +5,8 @@ const DEFAULT_KEYMAP = [
{ keys: [{ code: KeyboardEvent.DOM_VK_SEMICOLON, shift: true }], action: [ actions.CMD_OPEN ]},
{ keys: [{ code: KeyboardEvent.DOM_VK_O }], action: [ actions.CMD_TABS_OPEN, false ]},
{ keys: [{ code: KeyboardEvent.DOM_VK_O, shift: true }], action: [ actions.CMD_TABS_OPEN, true ]},
{ keys: [{ code: KeyboardEvent.DOM_VK_K }], action: [ actions.SCROLL_UP, 1 ]},
{ keys: [{ code: KeyboardEvent.DOM_VK_J }], action: [ actions.SCROLL_DOWN, 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_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_D }], action: [ actions.TABS_CLOSE ]},

@ -42,11 +42,8 @@ const invokeEvent = (action) => {
createFooterLine('open ');
}
break;
case actions.SCROLL_UP:
scrolls.scrollUp(window, action[1] || 1);
break;
case actions.SCROLL_DOWN:
scrolls.scrollDown(window, action[1] || 1);
case actions.SCROLL_LINES:
scrolls.scrollLines(window, action[1]);
break;
case actions.SCROLL_TOP:
scrolls.scrollTop(window, action[1]);

@ -1,12 +1,6 @@
const SCROLL_DELTA = 48;
const scrollUp = (page, count) => {
let x = page.scrollX;
let y = page.scrollY - SCROLL_DELTA * count;
page.scrollTo(x, y);
};
const scrollDown = (page, count) => {
const scrollLines = (page, count) => {
let x = page.scrollX;
let y = page.scrollY + SCROLL_DELTA * count;
page.scrollTo(x, y);
@ -24,4 +18,4 @@ const scrollBottom = (page) => {
page.scrollTo(x, y);
};
export { scrollUp, scrollDown, scrollTop, scrollBottom }
export { scrollLines, scrollTop, scrollBottom }

@ -5,8 +5,7 @@ export const TABS_REOPEN = 'tabs.reopen';
export const TABS_PREV = 'tabs.prev';
export const TABS_NEXT = 'tabs.next';
export const TABS_RELOAD = 'tabs.reload';
export const SCROLL_UP = 'scroll.up';
export const SCROLL_DOWN = 'scroll.down';
export const SCROLL_LINES = 'scroll.lines';
export const SCROLL_TOP = 'scroll.top';
export const SCROLL_BOTTOM = 'scroll.bottom';
export const FOLLOW_START = 'follow.start';
@ -30,8 +29,7 @@ const BACKGROUND_ACTION_SET = new Set([
const CONTENT_ACTION_SET = new Set([
CMD_OPEN,
CMD_TABS_OPEN,
SCROLL_UP,
SCROLL_DOWN,
SCROLL_LINES,
SCROLL_TOP,
SCROLL_BOTTOM,
FOLLOW_START,