1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-12 11:28:56 +00:00
trezor-wallet/src/utils/windowUtils.js
2019-01-03 15:05:55 +01:00

27 lines
897 B
JavaScript

/* @flow */
export const getViewportHeight = (): number => (
// $FlowIssue: "clientHeight" missing in null
document.documentElement.clientHeight || document.body.clientHeight
);
export const getScrollX = (): number => {
if (window.pageXOffset !== undefined) {
return window.pageXOffset;
} if (window.scrollLeft !== undefined) {
return window.scrollLeft;
}
// $FlowIssue: parentNode || scrollLeft missing
return (document.documentElement || document.body.parentNode || document.body).scrollLeft;
};
export const getScrollY = (): number => {
if (window.pageYOffset !== undefined) {
return window.pageYOffset;
} if (window.scrollTop !== undefined) {
return window.scrollTop;
}
// $FlowIssue: parentNode || scrollTop missing
return (document.documentElement || document.body.parentNode || document.body).scrollTop;
};