UNPKG

@nutui/nutui-react

Version:

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

53 lines (52 loc) 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function _export(target, all) { for(var name in all)Object.defineProperty(target, name, { enumerable: true, get: all[name] }); } _export(exports, { getRect: function() { return getRect; }, inBrowser: function() { return inBrowser; }, isWindow: function() { return isWindow; } }); var inBrowser = typeof document !== 'undefined' && !!document.scripts; function isWindow(val) { return val === window; } var getRect = function getRect(elementRef) { var element = elementRef; if (isWindow(element)) { var width = element.innerWidth; var height = element.innerHeight; return { top: 0, left: 0, right: width, bottom: height, width: width, height: height }; } if (element && element.getBoundingClientRect) { // console.log(element, element.getBoundingClientRect()) return element.getBoundingClientRect(); } return { top: 0, left: 0, right: 0, bottom: 0, width: 0, height: 0 }; };