Dashboard sipadu mbip
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

offset.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. exports.__esModule = true;
  4. exports.default = offset;
  5. var _contains = _interopRequireDefault(require("./contains"));
  6. var _isWindow = _interopRequireDefault(require("./isWindow"));
  7. var _ownerDocument = _interopRequireDefault(require("../ownerDocument"));
  8. function offset(node) {
  9. var doc = (0, _ownerDocument.default)(node),
  10. win = (0, _isWindow.default)(doc),
  11. docElem = doc && doc.documentElement,
  12. box = {
  13. top: 0,
  14. left: 0,
  15. height: 0,
  16. width: 0
  17. };
  18. if (!doc) return; // Make sure it's not a disconnected DOM node
  19. if (!(0, _contains.default)(docElem, node)) return box;
  20. if (node.getBoundingClientRect !== undefined) box = node.getBoundingClientRect(); // IE8 getBoundingClientRect doesn't support width & height
  21. box = {
  22. top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),
  23. left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0),
  24. width: (box.width == null ? node.offsetWidth : box.width) || 0,
  25. height: (box.height == null ? node.offsetHeight : box.height) || 0
  26. };
  27. return box;
  28. }
  29. module.exports = exports["default"];