diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-08-27 10:21:07 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-08-27 10:21:07 +0900 |
commit | 20e66ea2c7aa68dd5ffdb1af939e04d799969d90 (patch) | |
tree | bb1a2e8200cd8bb7cbd8e0a0dfa0a9268b167398 /src/content | |
parent | 02c0cfd97d44c8568dee6f0d11d2e45732309c67 (diff) |
scroll by pages
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/index.js | 3 | ||||
-rw-r--r-- | src/content/scrolls.js | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/content/index.js b/src/content/index.js index b233e27..feb169f 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -45,6 +45,9 @@ const invokeEvent = (action) => { case actions.SCROLL_LINES: scrolls.scrollLines(window, action[1]); break; + case actions.SCROLL_PAGES: + scrolls.scrollPages(window, action[1]); + break; case actions.SCROLL_TOP: scrolls.scrollTop(window, action[1]); break; diff --git a/src/content/scrolls.js b/src/content/scrolls.js index ef112a4..540703e 100644 --- a/src/content/scrolls.js +++ b/src/content/scrolls.js @@ -6,6 +6,13 @@ const scrollLines = (page, count) => { page.scrollTo(x, y); }; +const scrollPages = (page, count) => { + let height = page.innerHeight; + let x = page.scrollX; + let y = page.scrollY + height * count; + page.scrollTo(x, y); +}; + const scrollTop = (page) => { let x = page.scrollX; let y = 0; @@ -18,4 +25,4 @@ const scrollBottom = (page) => { page.scrollTo(x, y); }; -export { scrollLines, scrollTop, scrollBottom } +export { scrollLines, scrollPages, scrollTop, scrollBottom } |