From 8c84930ca3ca673ca2b6afa8973b2de5f0dc9cb3 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Mon, 9 Oct 2017 21:00:26 +0900 Subject: scroll horizonally --- src/content/scrolls.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/content/scrolls.js') 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 }; -- cgit v1.2.3 From cf36bf192ccbc6ffd175e4dd397b4a9140b7f28b Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Mon, 9 Oct 2017 21:01:22 +0900 Subject: fix method name --- src/content/actions/operation.js | 4 ++-- src/content/scrolls.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/content/scrolls.js') diff --git a/src/content/actions/operation.js b/src/content/actions/operation.js index 1302404..9187514 100644 --- a/src/content/actions/operation.js +++ b/src/content/actions/operation.js @@ -19,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 90bcc54..86ea554 100644 --- a/src/content/scrolls.js +++ b/src/content/scrolls.js @@ -32,13 +32,13 @@ 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); @@ -46,5 +46,5 @@ const scrollRight = (page) => { export { scrollVertically, scrollHorizonally, scrollPages, - scrollTop, scrollBottom, scrollLeft, scrollRight + scrollTop, scrollBottom, scrollHome, scrollEnd }; -- cgit v1.2.3