aboutsummaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-08-27 17:59:25 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-08-27 17:59:25 +0900
commit21404ad534278eff643be089da9c07882b29da82 (patch)
tree985d8efa303288e6a24c328496173825177e6e57 /src/content
parentb1908a28764850e650a1e0f2cebdb2f24c43d45a (diff)
support 0/$ commands
Diffstat (limited to 'src/content')
-rw-r--r--src/content/index.js10
-rw-r--r--src/content/scrolls.js14
2 files changed, 21 insertions, 3 deletions
diff --git a/src/content/index.js b/src/content/index.js
index 6bf5d57..9dd3706 100644
--- a/src/content/index.js
+++ b/src/content/index.js
@@ -49,10 +49,16 @@ const invokeEvent = (action) => {
scrolls.scrollPages(window, action[1]);
break;
case actions.SCROLL_TOP:
- scrolls.scrollTop(window, action[1]);
+ scrolls.scrollTop(window);
break;
case actions.SCROLL_BOTTOM:
- scrolls.scrollBottom(window, action[1]);
+ scrolls.scrollBottom(window);
+ break;
+ case actions.SCROLL_LEFT:
+ scrolls.scrollLeft(window);
+ break;
+ case actions.SCROLL_RIGHT:
+ scrolls.scrollRight(window);
break;
case actions.FOLLOW_START:
new Follow(window.document, action[1] || false);
diff --git a/src/content/scrolls.js b/src/content/scrolls.js
index 540703e..bc88e43 100644
--- a/src/content/scrolls.js
+++ b/src/content/scrolls.js
@@ -25,4 +25,16 @@ const scrollBottom = (page) => {
page.scrollTo(x, y);
};
-export { scrollLines, scrollPages, scrollTop, scrollBottom }
+const scrollLeft = (page) => {
+ let x = 0;
+ let y = page.scrollY;
+ page.scrollTo(x, y);
+};
+
+const scrollRight = (page) => {
+ let x = page.scrollMaxX;
+ let y = page.scrollY;
+ page.scrollTo(x, y);
+};
+
+export { scrollLines, scrollPages, scrollTop, scrollBottom, scrollLeft, scrollRight }