@rc-component/portal 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/useScrollLocker.js +2 -2
- package/lib/useScrollLocker.js +2 -2
- package/package.json +1 -1
package/es/useScrollLocker.js
CHANGED
|
@@ -2,7 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { updateCSS, removeCSS } from "rc-util/es/Dom/dynamicCSS";
|
|
4
4
|
import useLayoutEffect from "rc-util/es/hooks/useLayoutEffect";
|
|
5
|
-
import
|
|
5
|
+
import { getTargetScrollBarSize } from "rc-util/es/getScrollBarSize";
|
|
6
6
|
import { isBodyOverflowing } from "./util";
|
|
7
7
|
var UNIQUE_ID = "rc-util-locker-".concat(Date.now());
|
|
8
8
|
var uuid = 0;
|
|
@@ -16,7 +16,7 @@ export default function useScrollLocker(lock) {
|
|
|
16
16
|
id = _React$useState2[0];
|
|
17
17
|
useLayoutEffect(function () {
|
|
18
18
|
if (mergedLock) {
|
|
19
|
-
var scrollbarSize =
|
|
19
|
+
var scrollbarSize = getTargetScrollBarSize(document.body).width;
|
|
20
20
|
var isOverflow = isBodyOverflowing();
|
|
21
21
|
updateCSS("\nhtml body {\n overflow-y: hidden;\n ".concat(isOverflow ? "width: calc(100% - ".concat(scrollbarSize, "px);") : '', "\n}"), id);
|
|
22
22
|
} else {
|
package/lib/useScrollLocker.js
CHANGED
|
@@ -10,7 +10,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _dynamicCSS = require("rc-util/lib/Dom/dynamicCSS");
|
|
12
12
|
var _useLayoutEffect = _interopRequireDefault(require("rc-util/lib/hooks/useLayoutEffect"));
|
|
13
|
-
var _getScrollBarSize =
|
|
13
|
+
var _getScrollBarSize = require("rc-util/lib/getScrollBarSize");
|
|
14
14
|
var _util = require("./util");
|
|
15
15
|
var UNIQUE_ID = "rc-util-locker-".concat(Date.now());
|
|
16
16
|
var uuid = 0;
|
|
@@ -24,7 +24,7 @@ function useScrollLocker(lock) {
|
|
|
24
24
|
id = _React$useState2[0];
|
|
25
25
|
(0, _useLayoutEffect.default)(function () {
|
|
26
26
|
if (mergedLock) {
|
|
27
|
-
var scrollbarSize = (0, _getScrollBarSize.
|
|
27
|
+
var scrollbarSize = (0, _getScrollBarSize.getTargetScrollBarSize)(document.body).width;
|
|
28
28
|
var isOverflow = (0, _util.isBodyOverflowing)();
|
|
29
29
|
(0, _dynamicCSS.updateCSS)("\nhtml body {\n overflow-y: hidden;\n ".concat(isOverflow ? "width: calc(100% - ".concat(scrollbarSize, "px);") : '', "\n}"), id);
|
|
30
30
|
} else {
|