34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
define(["require", "exports", "./getWindow"], function (require, exports, getWindow_1) {
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.getRect = void 0;
|
|
/**
|
|
* Helper to get bounding client rect. Passing in window will get the window size.
|
|
*
|
|
* @public
|
|
*/
|
|
function getRect(element, win) {
|
|
var theWin = (win !== null && win !== void 0 ? win : (!element || (element && element.hasOwnProperty('devicePixelRatio'))))
|
|
? (0, getWindow_1.getWindow)()
|
|
: (0, getWindow_1.getWindow)(element);
|
|
var rect;
|
|
if (element) {
|
|
if (element === theWin) {
|
|
rect = {
|
|
left: 0,
|
|
top: 0,
|
|
width: theWin.innerWidth,
|
|
height: theWin.innerHeight,
|
|
right: theWin.innerWidth,
|
|
bottom: theWin.innerHeight,
|
|
};
|
|
}
|
|
else if (element.getBoundingClientRect) {
|
|
rect = element.getBoundingClientRect();
|
|
}
|
|
}
|
|
return rect;
|
|
}
|
|
exports.getRect = getRect;
|
|
});
|
|
//# sourceMappingURL=getRect.js.map
|