scroll horizonally

jh-changes
Shin'ya Ueoka 7 years ago
parent 36963b1b8b
commit 8c84930ca3
  1. 6
      src/content/actions/operation.js
  2. 16
      src/content/scrolls.js
  3. 6
      src/shared/default-settings.js
  4. 3
      src/shared/operations.js

@ -8,8 +8,10 @@ import * as consoleFrames from 'content/console-frames';
const exec = (operation) => {
switch (operation.type) {
case operations.SCROLL_LINES:
return scrolls.scrollLines(window, operation.count);
case operations.SCROLL_VERTICALLY:
return scrolls.scrollVertically(window, operation.count);
case operations.SCROLL_HORIZONALLY:
return scrolls.scrollHorizonally(window, operation.count);
case operations.SCROLL_PAGES:
return scrolls.scrollPages(window, operation.count);
case operations.SCROLL_TOP:

@ -1,8 +1,15 @@
const SCROLL_DELTA = 48;
const SCROLL_DELTA_X = 48;
const SCROLL_DELTA_Y = 48;
const scrollLines = (page, count) => {
const scrollVertically = (page, count) => {
let x = page.scrollX;
let y = page.scrollY + SCROLL_DELTA * count;
let y = page.scrollY + SCROLL_DELTA_X * count;
page.scrollTo(x, y);
};
const scrollHorizonally = (page, count) => {
let x = page.scrollX + SCROLL_DELTA_Y * count;
let y = page.scrollY;
page.scrollTo(x, y);
};
@ -38,5 +45,6 @@ const scrollRight = (page) => {
};
export {
scrollLines, scrollPages, scrollTop, scrollBottom, scrollLeft, scrollRight
scrollVertically, scrollHorizonally, scrollPages,
scrollTop, scrollBottom, scrollLeft, scrollRight
};

@ -11,8 +11,10 @@ export default {
"w": { "type": "command.show.winopen", "alter": false },
"W": { "type": "command.show.winopen", "alter": true },
"b": { "type": "command.show.buffer" },
"k": { "type": "scroll.lines", "count": -1 },
"j": { "type": "scroll.lines", "count": 1 },
"k": { "type": "scroll.vertically", "count": -1 },
"j": { "type": "scroll.vertically", "count": 1 },
"h": { "type": "scroll.horizonally", "count": -1 },
"l": { "type": "scroll.horizonally", "count": 1 },
"<C-E>": { "type": "scroll.lines", "count": -1 },
"<C-Y>": { "type": "scroll.lines", "count": 1 },
"<C-U>": { "type": "scroll.pages", "count": -0.5 },

@ -7,7 +7,8 @@ export default {
COMMAND_SHOW_BUFFER: 'command.show.buffer',
// Scrolls
SCROLL_LINES: 'scroll.lines',
SCROLL_VERTICALLY: 'scroll.vertically',
SCROLL_HORIZONALLY: 'scroll.horizonally',
SCROLL_PAGES: 'scroll.pages',
SCROLL_TOP: 'scroll.top',
SCROLL_BOTTOM: 'scroll.bottom',