You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
import getWindow from "./getWindow.js"; import getDocumentElement from "./getDocumentElement.js"; import getWindowScrollBarX from "./getWindowScrollBarX.js"; import isLayoutViewport from "./isLayoutViewport.js"; export default function getViewportRect(element, strategy) { var win = getWindow(element); var html = getDocumentElement(element); var visualViewport = win.visualViewport; var width = html.clientWidth; var height = html.clientHeight; var x = 0; var y = 0;
if (visualViewport) { width = visualViewport.width; height = visualViewport.height; var layoutViewport = isLayoutViewport();
if (layoutViewport || !layoutViewport && strategy === 'fixed') { x = visualViewport.offsetLeft; y = visualViewport.offsetTop; } }
return { width: width, height: height, x: x + getWindowScrollBarX(element), y: y }; }
|