Gazebo_simulation-Frontend/node_modules/dom-helpers/cjs/offset.js
2020-12-21 10:29:31 -05:00

37 lines
1.1 KiB
JavaScript

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = offset;
var _contains = _interopRequireDefault(require("./contains"));
var _ownerDocument = _interopRequireDefault(require("./ownerDocument"));
var _scrollLeft = _interopRequireDefault(require("./scrollLeft"));
var _scrollTop = _interopRequireDefault(require("./scrollTop"));
function offset(node) {
var doc = (0, _ownerDocument.default)(node);
var box = {
top: 0,
left: 0,
height: 0,
width: 0
};
var docElem = doc && doc.documentElement; // Make sure it's not a disconnected DOM node
if (!docElem || !(0, _contains.default)(docElem, node)) return box;
if (node.getBoundingClientRect !== undefined) box = node.getBoundingClientRect();
box = {
top: box.top + (0, _scrollTop.default)(node) - (docElem.clientTop || 0),
left: box.left + (0, _scrollLeft.default)(node) - (docElem.clientLeft || 0),
width: box.width,
height: box.height
};
return box;
}
module.exports = exports["default"];