aboutsummaryrefslogtreecommitdiff
path: root/src/content/scrolls.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/scrolls.js')
-rw-r--r--src/content/scrolls.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/content/scrolls.js b/src/content/scrolls.js
new file mode 100644
index 0000000..2a233c2
--- /dev/null
+++ b/src/content/scrolls.js
@@ -0,0 +1,27 @@
+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) => {
+ let x = page.scrollX;
+ let y = page.scrollY + SCROLL_DELTA * count;
+ page.scrollTo(x, y);
+};
+
+const scrollTop = (page) => {
+ let x = page.scrollX;
+ let y = 0;
+ page.scrollTo(x, y);
+};
+
+const scrollBottom = (page) => {
+ let x = page.scrollX;
+ let y = page.scrollMaxY;
+ page.scrollTo(x, y);
+};
+
+export { scrollUp, scrollDown, scrollTop, scrollBottom }