1
0
mirror of https://github.com/trezor/trezor-wallet synced 2025-07-05 14:22:35 +00:00
trezor-wallet/src/utils/windowUtils.js
2018-09-24 21:00:21 +02:00

27 lines
862 B
JavaScript

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