aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/content/actions/operation.js6
-rw-r--r--src/content/scrolls.js16
-rw-r--r--src/shared/default-settings.js6
-rw-r--r--src/shared/operations.js3
4 files changed, 22 insertions, 9 deletions
diff --git a/src/content/actions/operation.js b/src/content/actions/operation.js
index 0d5088b..1302404 100644
--- a/src/content/actions/operation.js
+++ b/src/content/actions/operation.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:
diff --git a/src/content/scrolls.js b/src/content/scrolls.js
index b1cea6f..90bcc54 100644
--- a/src/content/scrolls.js
+++ b/src/content/scrolls.js
@@ -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
};
diff --git a/src/shared/default-settings.js b/src/shared/default-settings.js
index 8db7727..ceacb50 100644
--- a/src/shared/default-settings.js
+++ b/src/shared/default-settings.js
@@ -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 },
diff --git a/src/shared/operations.js b/src/shared/operations.js
index ca62716..0d2a381 100644
--- a/src/shared/operations.js
+++ b/src/shared/operations.js
@@ -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',