UNPKG

dtd

Version:

根据数梦工场视觉规范打造的组件库,感谢react-components和ant design

1 lines 1.23 kB
import _typeof from"babel-runtime/helpers/typeof";export function getKey(t){return t._reactInternalFiber&&t._reactInternalFiber.key||Math.random().toString()};export var noop=function(){};export var isObject=function(t){return"object"===(void 0===t?"undefined":_typeof(t))};export var isString=function(t){return"string"==typeof t};export function getStyle(t,e){return t.style[e]?t.style[e]:t.currentStyle?t.currentStyle[e]:window.getComputedStyle(t,void 0)[e]};export function getSize(t){if("none"!==getStyle(t,"display"))return{width:t.offsetWidth||getStyleNum(t,"width"),height:t.offsetHeight||getStyleNum(t,"height")};var e={display:"",position:"absolute",visibility:"hidden"},r={};for(var i in e)r[i]=getStyle(t,i);setStyle(t,e);var n=t.clientWidth||getStyleNum(t,"width"),o=t.clientHeight||getStyleNum(t,"height");return Object.keys(r).forEach(function(){setStyle(t,r)}),{width:n,height:o}};export function getStyleNum(t,e){return parseInt(getStyle(t,e).replace(/px|pt|em/gi,""))};export function setStyle(t,e){if(isObject(e))for(var r in e){for(var i=r.split("-"),n=1;n<i.length;n++)i[n]=i[n].replace(i[n].charAt(0),i[n].charAt(0).toUpperCase());var o=i.join("");t.style[o]=e[r]}else isString(e)&&(t.style.cssText=e)};