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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
const SCROLL_DELTA_X = 48;
const SCROLL_DELTA_Y = 48;
const scrollVertically = (page, count) => {
let x = page.scrollX;
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);
};
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);
};
const scrollHome = (page) => {
let x = 0;
let y = page.scrollY;
page.scrollTo(x, y);
};
const scrollEnd = (page) => {
let x = page.scrollMaxX;
let y = page.scrollY;
page.scrollTo(x, y);
};
export {
scrollVertically, scrollHorizonally, scrollPages,
scrollTop, scrollBottom, scrollHome, scrollEnd
};
|