1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4 | Object.defineProperty(exports, "__esModule", {
|
5 | value: true
|
6 | });
|
7 | exports.default = void 0;
|
8 | var _getScrollBarSize = _interopRequireDefault(require("./getScrollBarSize"));
|
9 | var _setStyle = _interopRequireDefault(require("./setStyle"));
|
10 | function isBodyOverflowing() {
|
11 | return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight) && window.innerWidth > document.body.offsetWidth;
|
12 | }
|
13 | var cacheStyle = {};
|
14 | var _default = exports.default = function _default(close) {
|
15 | if (!isBodyOverflowing() && !close) {
|
16 | return;
|
17 | }
|
18 |
|
19 |
|
20 | var scrollingEffectClassName = 'ant-scrolling-effect';
|
21 | var scrollingEffectClassNameReg = new RegExp("".concat(scrollingEffectClassName), 'g');
|
22 | var bodyClassName = document.body.className;
|
23 | if (close) {
|
24 | if (!scrollingEffectClassNameReg.test(bodyClassName)) return;
|
25 | (0, _setStyle.default)(cacheStyle);
|
26 | cacheStyle = {};
|
27 | document.body.className = bodyClassName.replace(scrollingEffectClassNameReg, '').trim();
|
28 | return;
|
29 | }
|
30 | var scrollBarSize = (0, _getScrollBarSize.default)();
|
31 | if (scrollBarSize) {
|
32 | cacheStyle = (0, _setStyle.default)({
|
33 | position: 'relative',
|
34 | width: "calc(100% - ".concat(scrollBarSize, "px)")
|
35 | });
|
36 | if (!scrollingEffectClassNameReg.test(bodyClassName)) {
|
37 | var addClassName = "".concat(bodyClassName, " ").concat(scrollingEffectClassName);
|
38 | document.body.className = addClassName.trim();
|
39 | }
|
40 | }
|
41 | }; |
\ | No newline at end of file |