aboutsummaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
Diffstat (limited to 'src/content')
-rw-r--r--src/content/actions/operation.js10
-rw-r--r--src/content/scrolls.js20
2 files changed, 20 insertions, 10 deletions
diff --git a/src/content/actions/operation.js b/src/content/actions/operation.js
index 0d5088b..9187514 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:
@@ -17,9 +19,9 @@ const exec = (operation) => {
case operations.SCROLL_BOTTOM:
return scrolls.scrollBottom(window);
case operations.SCROLL_HOME:
- return scrolls.scrollLeft(window);
+ return scrolls.scrollHome(window);
case operations.SCROLL_END:
- return scrolls.scrollRight(window);
+ return scrolls.scrollEnd(window);
case operations.FOLLOW_START:
return followActions.enable(false);
case operations.NAVIGATE_HISTORY_PREV:
diff --git a/src/content/scrolls.js b/src/content/scrolls.js
index b1cea6f..86ea554 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);
};
@@ -25,18 +32,19 @@ const scrollBottom = (page) => {
page.scrollTo(x, y);
};
-const scrollLeft = (page) => {
+const scrollHome = (page) => {
let x = 0;
let y = page.scrollY;
page.scrollTo(x, y);
};
-const scrollRight = (page) => {
+const scrollEnd = (page) => {
let x = page.scrollMaxX;
let y = page.scrollY;
page.scrollTo(x, y);
};
export {
- scrollLines, scrollPages, scrollTop, scrollBottom, scrollLeft, scrollRight
+ scrollVertically, scrollHorizonally, scrollPages,
+ scrollTop, scrollBottom, scrollHome, scrollEnd
};