useContainerWidth.js 614 B

1234567891011121314151617181920
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = useContainerWidth;
  6. function useContainerWidth(prefixCls) {
  7. const getContainerWidth = (ele, width) => {
  8. const container = ele.querySelector(`.${prefixCls}-container`);
  9. let returnWidth = width;
  10. if (container) {
  11. const style = getComputedStyle(container);
  12. const borderLeft = parseInt(style.borderLeftWidth, 10);
  13. const borderRight = parseInt(style.borderRightWidth, 10);
  14. returnWidth = width - borderLeft - borderRight;
  15. }
  16. return returnWidth;
  17. };
  18. return getContainerWidth;
  19. }