2018-02-20 09:30:36 +00:00
|
|
|
/* @flow */
|
2018-07-30 10:52:13 +00:00
|
|
|
|
2019-03-04 12:33:02 +00:00
|
|
|
export const getViewportHeight = (): number =>
|
2019-01-02 12:38:35 +00:00
|
|
|
// $FlowIssue: "clientHeight" missing in null
|
2019-03-04 12:33:02 +00:00
|
|
|
document.documentElement.clientHeight || document.body.clientHeight;
|
2018-02-20 09:30:36 +00:00
|
|
|
|
2018-09-24 19:00:21 +00:00
|
|
|
export const getScrollX = (): number => {
|
|
|
|
if (window.pageXOffset !== undefined) {
|
|
|
|
return window.pageXOffset;
|
2019-03-04 12:33:02 +00:00
|
|
|
}
|
|
|
|
if (window.scrollLeft !== undefined) {
|
2018-09-24 19:00:21 +00:00
|
|
|
return window.scrollLeft;
|
|
|
|
}
|
2019-01-02 12:38:35 +00:00
|
|
|
// $FlowIssue: parentNode || scrollLeft missing
|
|
|
|
return (document.documentElement || document.body.parentNode || document.body).scrollLeft;
|
2018-09-24 19:00:21 +00:00
|
|
|
};
|
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
export const getScrollY = (): number => {
|
|
|
|
if (window.pageYOffset !== undefined) {
|
|
|
|
return window.pageYOffset;
|
2019-03-04 12:33:02 +00:00
|
|
|
}
|
|
|
|
if (window.scrollTop !== undefined) {
|
2018-02-20 09:30:36 +00:00
|
|
|
return window.scrollTop;
|
|
|
|
}
|
2019-01-02 12:38:35 +00:00
|
|
|
// $FlowIssue: parentNode || scrollTop missing
|
|
|
|
return (document.documentElement || document.body.parentNode || document.body).scrollTop;
|
2019-03-04 12:33:02 +00:00
|
|
|
};
|