1 line
675 B
JavaScript
1 line
675 B
JavaScript
import{isElement,isHTMLElement}from"./instanceOf.js";import{round}from"../utils/math.js";import getWindow from"./getWindow.js";import isLayoutViewport from"./isLayoutViewport.js";export default function getBoundingClientRect(t,i,e){void 0===i&&(i=!1),void 0===e&&(e=!1);var o=t.getBoundingClientRect(),f=1,n=1;i&&isHTMLElement(t)&&(f=0<t.offsetWidth&&round(o.width)/t.offsetWidth||1,n=0<t.offsetHeight&&round(o.height)/t.offsetHeight||1);i=(isElement(t)?getWindow(t):window).visualViewport,t=!isLayoutViewport()&&e,e=(o.left+(t&&i?i.offsetLeft:0))/f,t=(o.top+(t&&i?i.offsetTop:0))/n,i=o.width/f,f=o.height/n;return{width:i,height:f,top:t,right:e+i,bottom:t+f,left:e,x:e,y:t}} |