scrollbar-width.js 990 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. exports.__esModule = true;
  3. exports.default = function () {
  4. if (_vue2.default.prototype.$isServer) return 0;
  5. if (scrollBarWidth !== undefined) return scrollBarWidth;
  6. var outer = document.createElement('div');
  7. outer.className = 'el-scrollbar__wrap';
  8. outer.style.visibility = 'hidden';
  9. outer.style.width = '100px';
  10. outer.style.position = 'absolute';
  11. outer.style.top = '-9999px';
  12. document.body.appendChild(outer);
  13. var widthNoScroll = outer.offsetWidth;
  14. outer.style.overflow = 'scroll';
  15. var inner = document.createElement('div');
  16. inner.style.width = '100%';
  17. outer.appendChild(inner);
  18. var widthWithScroll = inner.offsetWidth;
  19. outer.parentNode.removeChild(outer);
  20. scrollBarWidth = widthNoScroll - widthWithScroll;
  21. return scrollBarWidth;
  22. };
  23. var _vue = require('vue');
  24. var _vue2 = _interopRequireDefault(_vue);
  25. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26. var scrollBarWidth = void 0;
  27. ;