in packages/mere-dom/src/util/get-viewport.ts [15:41]
export default function getViewport(): IViewport {
let scrollTop;
let scrollLeft;
let width;
let height;
if (window.visualViewport) {
({
pageTop: scrollTop,
pageLeft: scrollLeft,
width, // 不包含滚轴宽度
height
} = window.visualViewport);
} else {
width = document.documentElement.clientWidth;
height = document.documentElement.clientHeight;
scrollTop = window.scrollY || document.documentElement.scrollTop;
scrollLeft = window.scrollX || document.documentElement.scrollLeft;
}
return {
width: Math.round(width) || 0,
height: Math.round(height) || 0,
scrollTop: Math.round(scrollTop) || 0,
scrollLeft: Math.round(scrollLeft) || 0
};
}