@tamagui/remove-scroll 2.0.0-rc.4 → 2.0.0-rc.40
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/dist/cjs/RemoveScroll.cjs +16 -11
- package/dist/cjs/RemoveScroll.native.js +15 -13
- package/dist/cjs/RemoveScroll.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/useDisableScroll.cjs +88 -43
- package/dist/cjs/useDisableScroll.native.js +88 -45
- package/dist/cjs/useDisableScroll.native.js.map +1 -1
- package/dist/esm/RemoveScroll.mjs +4 -1
- package/dist/esm/RemoveScroll.mjs.map +1 -1
- package/dist/esm/RemoveScroll.native.js +3 -3
- package/dist/esm/RemoveScroll.native.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/useDisableScroll.mjs +76 -33
- package/dist/esm/useDisableScroll.mjs.map +1 -1
- package/dist/esm/useDisableScroll.native.js +74 -33
- package/dist/esm/useDisableScroll.native.js.map +1 -1
- package/dist/jsx/RemoveScroll.mjs +4 -1
- package/dist/jsx/RemoveScroll.mjs.map +1 -1
- package/dist/jsx/RemoveScroll.native.js +15 -13
- package/dist/jsx/RemoveScroll.native.js.map +1 -1
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/dist/jsx/useDisableScroll.mjs +76 -33
- package/dist/jsx/useDisableScroll.mjs.map +1 -1
- package/dist/jsx/useDisableScroll.native.js +88 -45
- package/dist/jsx/useDisableScroll.native.js.map +1 -1
- package/package.json +5 -8
- package/src/useDisableScroll.ts +3 -3
- package/types/RemoveScroll.d.ts.map +2 -2
- package/types/RemoveScroll.native.d.ts.map +2 -2
- package/types/index.d.ts.map +2 -2
- package/types/useDisableScroll.d.ts.map +3 -3
- package/dist/cjs/RemoveScroll.js +0 -22
- package/dist/cjs/RemoveScroll.js.map +0 -6
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/useDisableScroll.js +0 -57
- package/dist/cjs/useDisableScroll.js.map +0 -6
- package/dist/esm/RemoveScroll.js +0 -6
- package/dist/esm/RemoveScroll.js.map +0 -6
- package/dist/esm/useDisableScroll.js +0 -41
- package/dist/esm/useDisableScroll.js.map +0 -6
- package/dist/jsx/RemoveScroll.js +0 -6
- package/dist/jsx/RemoveScroll.js.map +0 -6
- package/dist/jsx/useDisableScroll.js +0 -41
- package/dist/jsx/useDisableScroll.js.map +0 -6
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var RemoveScroll_exports = {};
|
|
22
24
|
__export(RemoveScroll_exports, {
|
|
@@ -24,4 +26,7 @@ __export(RemoveScroll_exports, {
|
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(RemoveScroll_exports);
|
|
26
28
|
var import_useDisableScroll = require("./useDisableScroll.cjs");
|
|
27
|
-
const RemoveScroll = props =>
|
|
29
|
+
const RemoveScroll = props => {
|
|
30
|
+
(0, import_useDisableScroll.useDisableBodyScroll)(Boolean(props.enabled));
|
|
31
|
+
return props.children;
|
|
32
|
+
};
|
|
@@ -5,20 +5,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var RemoveScroll_native_exports = {};
|
|
24
26
|
__export(RemoveScroll_native_exports, {
|
|
@@ -27,7 +29,7 @@ __export(RemoveScroll_native_exports, {
|
|
|
27
29
|
});
|
|
28
30
|
module.exports = __toCommonJS(RemoveScroll_native_exports);
|
|
29
31
|
var RemoveScroll = function (props) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
return props.children;
|
|
33
|
+
};
|
|
34
|
+
var getAllowedScrollableNode = function () {};
|
|
33
35
|
//# sourceMappingURL=RemoveScroll.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RemoveScroll_native_exports","__export","RemoveScroll","getAllowedScrollableNode","module","exports","__toCommonJS","props","children"],"sources":["../../src/RemoveScroll.native.tsx"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["RemoveScroll_native_exports","__export","RemoveScroll","getAllowedScrollableNode","module","exports","__toCommonJS","props","children"],"sources":["../../src/RemoveScroll.native.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,2BAAA;AAAAC,QAAA,CAAAD,2BAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAA,YAAA;EAAAC,wBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAN,2BAAA;AAAO,IAAIE,YAAA,GAAe,SAAAA,CAASK,KAAA,EAAO;EACtC,OAAOA,KAAA,CAAMC,QAAA;AACjB;AACO,IAAIL,wBAAA,GAA2B,SAAAA,CAAA,EAAW,CAAC","ignoreList":[]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,15 +3,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
7
8
|
get: () => from[key],
|
|
8
9
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
10
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
15
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
-
value:
|
|
16
|
+
value: true
|
|
15
17
|
}), mod);
|
|
16
18
|
var index_exports = {};
|
|
17
19
|
module.exports = __toCommonJS(index_exports);
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -5,15 +5,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
9
10
|
get: () => from[key],
|
|
10
11
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
12
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
17
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
-
value:
|
|
18
|
+
value: true
|
|
17
19
|
}), mod);
|
|
18
20
|
var index_exports = {};
|
|
19
21
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA","ignoreList":[]}
|
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var useDisableScroll_exports = {};
|
|
22
24
|
__export(useDisableScroll_exports, {
|
|
@@ -24,46 +26,89 @@ __export(useDisableScroll_exports, {
|
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(useDisableScroll_exports);
|
|
26
28
|
var import_react = require("react");
|
|
27
|
-
const canUseDOM = () => typeof window
|
|
28
|
-
let refCount = 0
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const canUseDOM = () => typeof window !== "undefined" && !!window.document && !!window.document.createElement;
|
|
30
|
+
let refCount = 0;
|
|
31
|
+
let savedScrollY = 0;
|
|
32
|
+
let previousStyles = null;
|
|
31
33
|
function isIOSSafari() {
|
|
32
|
-
if (typeof navigator
|
|
33
|
-
const ua = navigator.userAgent
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
if (typeof navigator === "undefined") return false;
|
|
35
|
+
const ua = navigator.userAgent;
|
|
36
|
+
const isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
|
|
37
|
+
const isSafari = /^((?!chrome|android).)*safari/i.test(ua);
|
|
36
38
|
return isIOS && isSafari;
|
|
37
39
|
}
|
|
38
40
|
const useDisableBodyScroll = enabled => {
|
|
39
|
-
const wasEnabled = (0, import_react.useRef)(
|
|
41
|
+
const wasEnabled = (0, import_react.useRef)(false);
|
|
40
42
|
(0, import_react.useEffect)(() => {
|
|
41
|
-
if (canUseDOM()) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
if (!canUseDOM()) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (enabled && !wasEnabled.current) {
|
|
47
|
+
wasEnabled.current = true;
|
|
48
|
+
if (++refCount === 1) {
|
|
49
|
+
const html = document.documentElement;
|
|
50
|
+
const body = document.body;
|
|
51
|
+
savedScrollY = window.scrollY;
|
|
52
|
+
previousStyles = {
|
|
53
|
+
htmlOverflow: html.style.overflow,
|
|
54
|
+
htmlScrollbarGutter: html.style.scrollbarGutter,
|
|
55
|
+
bodyPosition: body.style.position,
|
|
56
|
+
bodyTop: body.style.top,
|
|
57
|
+
bodyWidth: body.style.width,
|
|
58
|
+
bodyOverflow: body.style.overflow,
|
|
59
|
+
bodyOverscrollBehavior: body.style.overscrollBehavior
|
|
60
|
+
};
|
|
61
|
+
html.style.scrollbarGutter = "stable";
|
|
62
|
+
html.style.overflow = "hidden";
|
|
63
|
+
body.style.overscrollBehavior = "none";
|
|
64
|
+
if (isIOSSafari()) {
|
|
65
|
+
body.style.position = "fixed";
|
|
66
|
+
body.style.top = `-${savedScrollY}px`;
|
|
67
|
+
body.style.width = "100%";
|
|
68
|
+
body.style.overflow = "hidden";
|
|
55
69
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
}
|
|
71
|
+
} else if (!enabled && wasEnabled.current) {
|
|
72
|
+
wasEnabled.current = false;
|
|
73
|
+
if (--refCount === 0 && previousStyles) {
|
|
74
|
+
const html = document.documentElement;
|
|
75
|
+
const body = document.body;
|
|
76
|
+
html.style.overflow = previousStyles.htmlOverflow;
|
|
77
|
+
html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
|
|
78
|
+
body.style.position = previousStyles.bodyPosition;
|
|
79
|
+
body.style.top = previousStyles.bodyTop;
|
|
80
|
+
body.style.width = previousStyles.bodyWidth;
|
|
81
|
+
body.style.overflow = previousStyles.bodyOverflow;
|
|
82
|
+
body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
|
|
83
|
+
if (savedScrollY > 0) {
|
|
84
|
+
window.scrollTo(0, savedScrollY);
|
|
85
|
+
}
|
|
86
|
+
previousStyles = null;
|
|
87
|
+
savedScrollY = 0;
|
|
60
88
|
}
|
|
61
89
|
}
|
|
62
|
-
}, [enabled])
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
90
|
+
}, [enabled]);
|
|
91
|
+
(0, import_react.useEffect)(() => {
|
|
92
|
+
return () => {
|
|
93
|
+
if (wasEnabled.current) {
|
|
94
|
+
wasEnabled.current = false;
|
|
95
|
+
if (--refCount === 0 && previousStyles) {
|
|
96
|
+
const html = document.documentElement;
|
|
97
|
+
const body = document.body;
|
|
98
|
+
html.style.overflow = previousStyles.htmlOverflow;
|
|
99
|
+
html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
|
|
100
|
+
body.style.position = previousStyles.bodyPosition;
|
|
101
|
+
body.style.top = previousStyles.bodyTop;
|
|
102
|
+
body.style.width = previousStyles.bodyWidth;
|
|
103
|
+
body.style.overflow = previousStyles.bodyOverflow;
|
|
104
|
+
body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
|
|
105
|
+
if (savedScrollY > 0) {
|
|
106
|
+
window.scrollTo(0, savedScrollY);
|
|
107
|
+
}
|
|
108
|
+
previousStyles = null;
|
|
109
|
+
savedScrollY = 0;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
68
113
|
}, []);
|
|
69
114
|
};
|
|
@@ -5,70 +5,113 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var useDisableScroll_exports = {};
|
|
24
26
|
__export(useDisableScroll_exports, {
|
|
25
27
|
useDisableBodyScroll: () => useDisableBodyScroll
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(useDisableScroll_exports);
|
|
28
|
-
var import_react = require("react")
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var canUseDOM = function () {
|
|
32
|
+
return typeof window !== "undefined" && !!window.document && !!window.document.createElement;
|
|
33
|
+
};
|
|
34
|
+
var refCount = 0;
|
|
35
|
+
var savedScrollY = 0;
|
|
36
|
+
var previousStyles = null;
|
|
35
37
|
function isIOSSafari() {
|
|
36
|
-
if (typeof navigator
|
|
37
|
-
var ua = navigator.userAgent
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
if (typeof navigator === "undefined") return false;
|
|
39
|
+
var ua = navigator.userAgent;
|
|
40
|
+
var isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
|
|
41
|
+
var isSafari = /^((?!chrome|android).)*safari/i.test(ua);
|
|
40
42
|
return isIOS && isSafari;
|
|
41
43
|
}
|
|
42
44
|
var useDisableBodyScroll = function (enabled) {
|
|
43
|
-
var wasEnabled = (0, import_react.useRef)(
|
|
45
|
+
var wasEnabled = (0, import_react.useRef)(false);
|
|
44
46
|
(0, import_react.useEffect)(function () {
|
|
45
|
-
if (canUseDOM()) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
if (!canUseDOM()) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (enabled && !wasEnabled.current) {
|
|
51
|
+
wasEnabled.current = true;
|
|
52
|
+
if (++refCount === 1) {
|
|
53
|
+
var html = document.documentElement;
|
|
54
|
+
var body = document.body;
|
|
55
|
+
savedScrollY = window.scrollY;
|
|
56
|
+
previousStyles = {
|
|
57
|
+
htmlOverflow: html.style.overflow,
|
|
58
|
+
htmlScrollbarGutter: html.style.scrollbarGutter,
|
|
59
|
+
bodyPosition: body.style.position,
|
|
60
|
+
bodyTop: body.style.top,
|
|
61
|
+
bodyWidth: body.style.width,
|
|
62
|
+
bodyOverflow: body.style.overflow,
|
|
63
|
+
bodyOverscrollBehavior: body.style.overscrollBehavior
|
|
64
|
+
};
|
|
65
|
+
html.style.scrollbarGutter = "stable";
|
|
66
|
+
html.style.overflow = "hidden";
|
|
67
|
+
body.style.overscrollBehavior = "none";
|
|
68
|
+
if (isIOSSafari()) {
|
|
69
|
+
body.style.position = "fixed";
|
|
70
|
+
body.style.top = `-${savedScrollY}px`;
|
|
71
|
+
body.style.width = "100%";
|
|
72
|
+
body.style.overflow = "hidden";
|
|
59
73
|
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
74
|
+
}
|
|
75
|
+
} else if (!enabled && wasEnabled.current) {
|
|
76
|
+
wasEnabled.current = false;
|
|
77
|
+
if (--refCount === 0 && previousStyles) {
|
|
78
|
+
var html1 = document.documentElement;
|
|
79
|
+
var body1 = document.body;
|
|
80
|
+
html1.style.overflow = previousStyles.htmlOverflow;
|
|
81
|
+
html1.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
|
|
82
|
+
body1.style.position = previousStyles.bodyPosition;
|
|
83
|
+
body1.style.top = previousStyles.bodyTop;
|
|
84
|
+
body1.style.width = previousStyles.bodyWidth;
|
|
85
|
+
body1.style.overflow = previousStyles.bodyOverflow;
|
|
86
|
+
body1.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
|
|
87
|
+
if (savedScrollY > 0) {
|
|
88
|
+
window.scrollTo(0, savedScrollY);
|
|
89
|
+
}
|
|
90
|
+
previousStyles = null;
|
|
91
|
+
savedScrollY = 0;
|
|
64
92
|
}
|
|
65
93
|
}
|
|
66
|
-
}, [enabled])
|
|
94
|
+
}, [enabled]);
|
|
95
|
+
(0, import_react.useEffect)(function () {
|
|
67
96
|
return function () {
|
|
68
|
-
if (wasEnabled.current
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
97
|
+
if (wasEnabled.current) {
|
|
98
|
+
wasEnabled.current = false;
|
|
99
|
+
if (--refCount === 0 && previousStyles) {
|
|
100
|
+
var html = document.documentElement;
|
|
101
|
+
var body = document.body;
|
|
102
|
+
html.style.overflow = previousStyles.htmlOverflow;
|
|
103
|
+
html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
|
|
104
|
+
body.style.position = previousStyles.bodyPosition;
|
|
105
|
+
body.style.top = previousStyles.bodyTop;
|
|
106
|
+
body.style.width = previousStyles.bodyWidth;
|
|
107
|
+
body.style.overflow = previousStyles.bodyOverflow;
|
|
108
|
+
body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
|
|
109
|
+
if (savedScrollY > 0) {
|
|
110
|
+
window.scrollTo(0, savedScrollY);
|
|
111
|
+
}
|
|
112
|
+
previousStyles = null;
|
|
113
|
+
savedScrollY = 0;
|
|
114
|
+
}
|
|
72
115
|
}
|
|
73
116
|
};
|
|
74
117
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useDisableScroll_exports","__export","useDisableBodyScroll","module","exports","import_react","require","canUseDOM","window","document","createElement","refCount","savedScrollY","previousStyles","isIOSSafari","navigator","ua","userAgent","isIOS","test","platform","maxTouchPoints","isSafari","enabled","wasEnabled","useRef","useEffect","current","html","documentElement","body","scrollY","htmlOverflow","style","overflow","htmlScrollbarGutter","scrollbarGutter","bodyPosition","position","bodyTop","top","bodyWidth","width","bodyOverflow","bodyOverscrollBehavior","overscrollBehavior","html1","body1","scrollTo"],"sources":["../../src/useDisableScroll.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useDisableScroll_exports","__export","useDisableBodyScroll","module","exports","import_react","require","canUseDOM","window","document","createElement","refCount","savedScrollY","previousStyles","isIOSSafari","navigator","ua","userAgent","isIOS","test","platform","maxTouchPoints","isSafari","enabled","wasEnabled","useRef","useEffect","current","html","documentElement","body","scrollY","htmlOverflow","style","overflow","htmlScrollbarGutter","scrollbarGutter","bodyPosition","position","bodyTop","top","bodyWidth","width","bodyOverflow","bodyOverscrollBehavior","overscrollBehavior","html1","body1","scrollTo"],"sources":["../../src/useDisableScroll.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,wBAAA;AAAAC,QAAA,CAAAD,wBAAA;EAAAE,oBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAkC,CAAAK,wBAAA;AAElC,IAAAK,YAAM,GAAYC,OAChB,QAAO;AAET,IAAIC,SAAA,GAAW,SAAAA,CAAA;EACf,OAAI,OAAAC,MAAe,sBAAAA,MAAA,CAAAC,QAAA,MAAAD,MAAA,CAAAC,QAAA,CAAAC,aAAA;AACnB;AAWA,IAAAC,QAAS;AACP,IAAAC,YAAW;AACX,IAAAC,cAAW,OAAU;AACrB,SAAMC,WACJA,CAAA;EAEF,WAAMC,SAAW,8BAAiC;EAClD,IAAAC,EAAA,GAAOD,SAAS,CAAAE,SAAA;EAClB,IAAAC,K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A,CAAKK,KAAA,CAAMC,QAAA,GAAWrB,cAAA,CAAemB,YAAA;UACrCJ,IAAA,CAAKK,KAAA,CAAMG,eAAA,GAAAvB,cAAqB,CAAAsB,mBAAe;UAE/CL,IAAI,CAAAG,KAAA,CAAAK,QAAe,GAAGzB,cAAA,CAAAwB,YAAA;UACpBP,IAAA,CAAAG,KAAO,CAAAO,GAAA,GAAA3B,cAAY,CAAA0B,OAAY;UACjCT,IAAA,CAAAG,KAAA,CAAAS,KAAA,GAAA7B,cAAA,CAAA4B,SAAA;UAEAX,IAAA,CAAAG,KAAA,CAAAC,QAAiB,GAAArB,cAAA,CAAA8B,YAAA;UACjBb,IAAA,CAAAG,KAAA,CAAAY,kBAAe,GAAAhC,cAAA,CAAA+B,sBAAA;UACjB,IAAAhC,YAAA;YACFJ,MAAA,CAAAwC,QAAA,IAAApC,YAAA;UACF;UACGC,cAAA;UACPD,YAAA","ignoreList":[]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { useDisableBodyScroll } from "./useDisableScroll.mjs";
|
|
2
|
-
const RemoveScroll = props =>
|
|
2
|
+
const RemoveScroll = props => {
|
|
3
|
+
useDisableBodyScroll(Boolean(props.enabled));
|
|
4
|
+
return props.children;
|
|
5
|
+
};
|
|
3
6
|
export { RemoveScroll };
|
|
4
7
|
//# sourceMappingURL=RemoveScroll.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useDisableBodyScroll","RemoveScroll","props","enabled","children"],"sources":["../../src/RemoveScroll.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,oBAAA,QAA4B;AAO9B,MAAMC,YAAA,GAAgBC,KAAA,
|
|
1
|
+
{"version":3,"names":["useDisableBodyScroll","RemoveScroll","props","Boolean","enabled","children"],"sources":["../../src/RemoveScroll.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,oBAAA,QAA4B;AAO9B,MAAMC,YAAA,GAAgBC,KAAA,IAAwC;EACnEF,oBAAA,CAAqBG,OAAA,CAAQD,KAAA,CAAME,OAAO,CAAC;EAE3C,OAAOF,KAAA,CAAMG,QAAA;AACf","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var RemoveScroll = function (props) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
return props.children;
|
|
3
|
+
};
|
|
4
|
+
var getAllowedScrollableNode = function () {};
|
|
5
5
|
export { RemoveScroll, getAllowedScrollableNode };
|
|
6
6
|
//# sourceMappingURL=RemoveScroll.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RemoveScroll","props","children","getAllowedScrollableNode"],"sources":["../../src/RemoveScroll.native.tsx"],"sourcesContent":[null],"mappings":"AAAO,IAAIA,YAAA,GAAe,SAAAA,CAASC,KAAA,EAAO;
|
|
1
|
+
{"version":3,"names":["RemoveScroll","props","children","getAllowedScrollableNode"],"sources":["../../src/RemoveScroll.native.tsx"],"sourcesContent":[null],"mappings":"AAAO,IAAIA,YAAA,GAAe,SAAAA,CAASC,KAAA,EAAO;EACtC,OAAOA,KAAA,CAAMC,QAAA;AACjB;AACO,IAAIC,wBAAA,GAA2B,SAAAA,CAAA,EAAW,CAAC","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./RemoveScroll";
|
|
1
|
+
export * from "./RemoveScroll.mjs";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|