get-outer-width.js 569 B

1234567891011121314
  1. /**
  2. * 获取外层宽度
  3. * @param {HTMLElement} el dom节点
  4. * @param {Number} defaultValue 默认值
  5. * @return {Number} 宽度
  6. */
  7. module.exports = function getOuterWidth(el, defaultValue) {
  8. var width = this.getWidth(el, defaultValue);
  9. var bLeft = parseFloat(this.getStyle(el, 'borderLeftWidth')) || 0;
  10. var pLeft = parseFloat(this.getStyle(el, 'paddingLeft')) || 0;
  11. var pRight = parseFloat(this.getStyle(el, 'paddingRight')) || 0;
  12. var bRight = parseFloat(this.getStyle(el, 'borderRightWidth')) || 0;
  13. return width + bLeft + bRight + pLeft + pRight;
  14. };