aboutsummaryrefslogtreecommitdiff
path: root/src/content/scrolls.js
blob: 540703e3f76cb80e87ffdb8c9d601b91c40b26e7 (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
28
const SCROLL_DELTA = 48;

const scrollLines = (page, count) => {
  let x = page.scrollX;
  let y = page.scrollY + SCROLL_DELTA * 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;
  page.scrollTo(x, y);
};

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

export { scrollLines, scrollPages, scrollTop, scrollBottom }