aboutsummaryrefslogtreecommitdiff
path: root/src/content/scrolls.js
blob: e640384121af11a4cd3ffc6f10696ee94b08b93d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const SCROLL_DELTA = 48;

const scrollUp = (page, count) => {
  let x = page.scrollX;
  var y = page.scrollY - SCROLL_DELTA * count;
  page.scrollTo(x, y);
};

const scrollDown = (page, count) => {
  let x = page.scrollX;
  var y = page.scrollY + SCROLL_DELTA * count;
  page.scrollTo(x, y);
};

const scrollToTop = (page) => {
  let x = page.scrollX;
  var y = page.scrollMaxY;
  page.scrollTo(x, y);
};

const scrollToBottom = (page) => {
  let x = page.scrollX;
  var y = 0;
  page.scrollTo(x, y);
};

export { scrollUp, scrollDown, scrollToTop, scrollToBottom }