GoScrobble/web/node_modules/dom-helpers/cjs/scrollbarSize.js

30 lines
812 B
JavaScript
Raw Permalink Normal View History

2022-04-25 02:47:15 +00:00
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = scrollbarSize;
var _canUseDOM = _interopRequireDefault(require("./canUseDOM"));
var size;
function scrollbarSize(recalc) {
if (!size && size !== 0 || recalc) {
if (_canUseDOM.default) {
var scrollDiv = document.createElement('div');
scrollDiv.style.position = 'absolute';
scrollDiv.style.top = '-9999px';
scrollDiv.style.width = '50px';
scrollDiv.style.height = '50px';
scrollDiv.style.overflow = 'scroll';
document.body.appendChild(scrollDiv);
size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
}
}
return size;
}
module.exports = exports["default"];