UNPKG

gui-one-nutui-react-taro

Version:

京东风格的轻量级移动端 React 组件库,支持一套代码生成 H5 和小程序

36 lines (35 loc) 1.24 kB
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; import _regeneratorRuntime from "@babel/runtime/regenerator"; /** 获取元素的大小及其相对于视口的位置,等价于 Element.getBoundingClientRect。 width 宽度 number height 高度 number top 顶部与视图窗口左上角的距离 number left 左侧与视图窗口左上角的距离 number right 右侧与视图窗口左上角的距离 number bottom 底部与视图窗口左上角的距离 number */ var getRectByTaro = /*#__PURE__*/function () { var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(element) { var res; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return element.getBoundingClientRect(); case 2: res = _context.sent; return _context.abrupt("return", res); case 4: case "end": return _context.stop(); } } }, _callee); })); return function getRectByTaro(_x) { return _ref.apply(this, arguments); }; }(); export { getRectByTaro as g };