cd54521013337be6f9d29ccd10e488b8.json 10.5 KB
{"ast":null,"code":"/* eslint-disable no-nested-ternary */\nvar PIXEL_PATTERN = /margin|padding|width|height|max|min|offset/;\nvar removePixel = {\n  left: true,\n  top: true\n};\nvar floatMap = {\n  cssFloat: 1,\n  styleFloat: 1,\n  float: 1\n};\n\nfunction getComputedStyle(node) {\n  return node.nodeType === 1 ? node.ownerDocument.defaultView.getComputedStyle(node, null) : {};\n}\n\nfunction getStyleValue(node, type, value) {\n  type = type.toLowerCase();\n\n  if (value === 'auto') {\n    if (type === 'height') {\n      return node.offsetHeight;\n    }\n\n    if (type === 'width') {\n      return node.offsetWidth;\n    }\n  }\n\n  if (!(type in removePixel)) {\n    removePixel[type] = PIXEL_PATTERN.test(type);\n  }\n\n  return removePixel[type] ? parseFloat(value) || 0 : value;\n}\n\nexport function get(node, name) {\n  var length = arguments.length;\n  var style = getComputedStyle(node);\n  name = floatMap[name] ? 'cssFloat' in node.style ? 'cssFloat' : 'styleFloat' : name;\n  return length === 1 ? style : getStyleValue(node, name, style[name] || node.style[name]);\n}\nexport function set(node, name, value) {\n  var length = arguments.length;\n  name = floatMap[name] ? 'cssFloat' in node.style ? 'cssFloat' : 'styleFloat' : name;\n\n  if (length === 3) {\n    if (typeof value === 'number' && PIXEL_PATTERN.test(name)) {\n      value = \"\".concat(value, \"px\");\n    }\n\n    node.style[name] = value; // Number\n\n    return value;\n  }\n\n  for (var x in name) {\n    if (name.hasOwnProperty(x)) {\n      set(node, x, name[x]);\n    }\n  }\n\n  return getComputedStyle(node);\n}\nexport function getOuterWidth(el) {\n  if (el === document.body) {\n    return document.documentElement.clientWidth;\n  }\n\n  return el.offsetWidth;\n}\nexport function getOuterHeight(el) {\n  if (el === document.body) {\n    return window.innerHeight || document.documentElement.clientHeight;\n  }\n\n  return el.offsetHeight;\n}\nexport function getDocSize() {\n  var width = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);\n  var height = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);\n  return {\n    width: width,\n    height: height\n  };\n}\nexport function getClientSize() {\n  var width = document.documentElement.clientWidth;\n  var height = window.innerHeight || document.documentElement.clientHeight;\n  return {\n    width: width,\n    height: height\n  };\n}\nexport function getScroll() {\n  return {\n    scrollLeft: Math.max(document.documentElement.scrollLeft, document.body.scrollLeft),\n    scrollTop: Math.max(document.documentElement.scrollTop, document.body.scrollTop)\n  };\n}\nexport function getOffset(node) {\n  var box = node.getBoundingClientRect();\n  var docElem = document.documentElement; // < ie8 不支持 win.pageXOffset, 则使用 docElem.scrollLeft\n\n  return {\n    left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || document.body.clientLeft || 0),\n    top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || document.body.clientTop || 0)\n  };\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-util/es/Dom/css.js"],"names":["PIXEL_PATTERN","removePixel","left","top","floatMap","cssFloat","styleFloat","float","getComputedStyle","node","nodeType","ownerDocument","defaultView","getStyleValue","type","value","toLowerCase","offsetHeight","offsetWidth","test","parseFloat","get","name","length","arguments","style","set","concat","x","hasOwnProperty","getOuterWidth","el","document","body","documentElement","clientWidth","getOuterHeight","window","innerHeight","clientHeight","getDocSize","width","Math","max","scrollWidth","height","scrollHeight","getClientSize","getScroll","scrollLeft","scrollTop","getOffset","box","getBoundingClientRect","docElem","pageXOffset","clientLeft","pageYOffset","clientTop"],"mappings":"AAAA;AACA,IAAIA,aAAa,GAAG,4CAApB;AACA,IAAIC,WAAW,GAAG;AAChBC,EAAAA,IAAI,EAAE,IADU;AAEhBC,EAAAA,GAAG,EAAE;AAFW,CAAlB;AAIA,IAAIC,QAAQ,GAAG;AACbC,EAAAA,QAAQ,EAAE,CADG;AAEbC,EAAAA,UAAU,EAAE,CAFC;AAGbC,EAAAA,KAAK,EAAE;AAHM,CAAf;;AAMA,SAASC,gBAAT,CAA0BC,IAA1B,EAAgC;AAC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OAAO,CAACE,UAAR,IAAsBxB,QAAQ,CAACC,IAAT,CAAcuB,UAApC,IAAkD,CAA3G,CADD;AAELrD,IAAAA,GAAG,EAAEiD,GAAG,CAACjD,GAAJ,IAAWkC,MAAM,CAACoB,WAAP,IAAsBH,OAAO,CAACJ,SAAzC,KAAuDI,OAAO,CAACI,SAAR,IAAqB1B,QAAQ,CAACC,IAAT,CAAcyB,SAAnC,IAAgD,CAAvG;AAFA,GAAP;AAID","sourcesContent":["/* eslint-disable no-nested-ternary */\nvar PIXEL_PATTERN = /margin|padding|width|height|max|min|offset/;\nvar removePixel = {\n  left: true,\n  top: true\n};\nvar floatMap = {\n  cssFloat: 1,\n  styleFloat: 1,\n  float: 1\n};\n\nfunction getComputedStyle(node) {\n  return node.nodeType === 1 ? node.ownerDocument.defaultView.getComputedStyle(node, null) : {};\n}\n\nfunction getStyleValue(node, type, value) {\n  type = type.toLowerCase();\n\n  if (value === 'auto') {\n    if (type === 'height') {\n      return node.offsetHeight;\n    }\n\n    if (type === 'width') {\n      return node.offsetWidth;\n    }\n  }\n\n  if (!(type in removePixel)) {\n    removePixel[type] = PIXEL_PATTERN.test(type);\n  }\n\n  return removePixel[type] ? parseFloat(value) || 0 : value;\n}\n\nexport function get(node, name) {\n  var length = arguments.length;\n  var style = getComputedStyle(node);\n  name = floatMap[name] ? 'cssFloat' in node.style ? 'cssFloat' : 'styleFloat' : name;\n  return length === 1 ? style : getStyleValue(node, name, style[name] || node.style[name]);\n}\nexport function set(node, name, value) {\n  var length = arguments.length;\n  name = floatMap[name] ? 'cssFloat' in node.style ? 'cssFloat' : 'styleFloat' : name;\n\n  if (length === 3) {\n    if (typeof value === 'number' && PIXEL_PATTERN.test(name)) {\n      value = \"\".concat(value, \"px\");\n    }\n\n    node.style[name] = value; // Number\n\n    return value;\n  }\n\n  for (var x in name) {\n    if (name.hasOwnProperty(x)) {\n      set(node, x, name[x]);\n    }\n  }\n\n  return getComputedStyle(node);\n}\nexport function getOuterWidth(el) {\n  if (el === document.body) {\n    return document.documentElement.clientWidth;\n  }\n\n  return el.offsetWidth;\n}\nexport function getOuterHeight(el) {\n  if (el === document.body) {\n    return window.innerHeight || document.documentElement.clientHeight;\n  }\n\n  return el.offsetHeight;\n}\nexport function getDocSize() {\n  var width = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);\n  var height = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);\n  return {\n    width: width,\n    height: height\n  };\n}\nexport function getClientSize() {\n  var width = document.documentElement.clientWidth;\n  var height = window.innerHeight || document.documentElement.clientHeight;\n  return {\n    width: width,\n    height: height\n  };\n}\nexport function getScroll() {\n  return {\n    scrollLeft: Math.max(document.documentElement.scrollLeft, document.body.scrollLeft),\n    scrollTop: Math.max(document.documentElement.scrollTop, document.body.scrollTop)\n  };\n}\nexport function getOffset(node) {\n  var box = node.getBoundingClientRect();\n  var docElem = document.documentElement; // < ie8 不支持 win.pageXOffset, 则使用 docElem.scrollLeft\n\n  return {\n    left: box.left + (window.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || document.body.clientLeft || 0),\n    top: box.top + (window.pageYOffset || docElem.scrollTop) - (docElem.clientTop || document.body.clientTop || 0)\n  };\n}"]},"metadata":{},"sourceType":"module"}