@tamagui/remove-scroll 2.7.7 → 3.0.0-beta.643.1
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 +18 -21
- package/dist/cjs/RemoveScroll.native.cjs +33 -0
- package/dist/cjs/RemoveScroll.native.js +19 -19
- package/dist/cjs/RemoveScroll.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/useDisableScroll.cjs +94 -97
- package/dist/cjs/useDisableScroll.native.cjs +115 -0
- package/dist/cjs/useDisableScroll.native.js +96 -98
- package/dist/cjs/useDisableScroll.native.js.map +1 -1
- package/dist/esm/RemoveScroll.mjs +5 -3
- package/dist/esm/RemoveScroll.mjs.map +1 -1
- package/dist/esm/RemoveScroll.native.js +4 -3
- package/dist/esm/RemoveScroll.native.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/index.native.js +1 -2
- package/dist/esm/useDisableScroll.mjs +81 -79
- package/dist/esm/useDisableScroll.mjs.map +1 -1
- package/dist/esm/useDisableScroll.native.js +83 -81
- package/dist/esm/useDisableScroll.native.js.map +1 -1
- package/dist/jsx/RemoveScroll.mjs +5 -3
- package/dist/jsx/RemoveScroll.mjs.map +1 -1
- package/dist/jsx/RemoveScroll.native.cjs +33 -0
- package/dist/jsx/RemoveScroll.native.js +19 -19
- package/dist/jsx/RemoveScroll.native.js.map +1 -1
- package/dist/jsx/index.js +1 -2
- package/dist/jsx/index.mjs +1 -2
- package/dist/jsx/index.native.cjs +21 -0
- package/dist/jsx/index.native.js +10 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/useDisableScroll.mjs +81 -79
- package/dist/jsx/useDisableScroll.mjs.map +1 -1
- package/dist/jsx/useDisableScroll.native.cjs +115 -0
- package/dist/jsx/useDisableScroll.native.js +96 -98
- package/dist/jsx/useDisableScroll.native.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
|
@@ -1,119 +1,117 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
24
|
var useDisableScroll_exports = {};
|
|
26
|
-
__export(useDisableScroll_exports, {
|
|
27
|
-
useDisableBodyScroll: () => useDisableBodyScroll
|
|
28
|
-
});
|
|
25
|
+
__export(useDisableScroll_exports, { useDisableBodyScroll: () => useDisableBodyScroll });
|
|
29
26
|
module.exports = __toCommonJS(useDisableScroll_exports);
|
|
30
27
|
var import_react = require("react");
|
|
31
|
-
var canUseDOM = function
|
|
32
|
-
|
|
28
|
+
var canUseDOM = function() {
|
|
29
|
+
return typeof window !== "undefined" && !!window.document && !!window.document.createElement;
|
|
33
30
|
};
|
|
34
31
|
var refCount = 0;
|
|
35
32
|
var savedScrollY = 0;
|
|
36
33
|
var previousStyles = null;
|
|
37
34
|
function isIOSSafari() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
if (typeof navigator === "undefined") return false;
|
|
36
|
+
var ua = navigator.userAgent;
|
|
37
|
+
var isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
|
|
38
|
+
var isSafari = /^((?!chrome|android).)*safari/i.test(ua);
|
|
39
|
+
return isIOS && isSafari;
|
|
43
40
|
}
|
|
44
|
-
var useDisableBodyScroll = function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
41
|
+
var useDisableBodyScroll = function(enabled) {
|
|
42
|
+
var wasEnabled = (0, import_react.useRef)(false);
|
|
43
|
+
(0, import_react.useEffect)(function() {
|
|
44
|
+
if (!canUseDOM()) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (enabled && !wasEnabled.current) {
|
|
48
|
+
wasEnabled.current = true;
|
|
49
|
+
if (++refCount === 1) {
|
|
50
|
+
var html = document.documentElement;
|
|
51
|
+
var body = document.body;
|
|
52
|
+
savedScrollY = window.scrollY;
|
|
53
|
+
previousStyles = {
|
|
54
|
+
htmlOverflow: html.style.overflow,
|
|
55
|
+
htmlScrollbarGutter: html.style.scrollbarGutter,
|
|
56
|
+
bodyPosition: body.style.position,
|
|
57
|
+
bodyTop: body.style.top,
|
|
58
|
+
bodyWidth: body.style.width,
|
|
59
|
+
bodyOverflow: body.style.overflow,
|
|
60
|
+
bodyOverscrollBehavior: body.style.overscrollBehavior
|
|
61
|
+
};
|
|
62
|
+
html.style.scrollbarGutter = "stable";
|
|
63
|
+
html.style.overflow = "hidden";
|
|
64
|
+
body.style.overscrollBehavior = "none";
|
|
65
|
+
if (isIOSSafari()) {
|
|
66
|
+
body.style.position = "fixed";
|
|
67
|
+
body.style.top = `-${savedScrollY}px`;
|
|
68
|
+
body.style.width = "100%";
|
|
69
|
+
body.style.overflow = "hidden";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} else if (!enabled && wasEnabled.current) {
|
|
73
|
+
wasEnabled.current = false;
|
|
74
|
+
if (--refCount === 0 && previousStyles) {
|
|
75
|
+
var html1 = document.documentElement;
|
|
76
|
+
var body1 = document.body;
|
|
77
|
+
html1.style.overflow = previousStyles.htmlOverflow;
|
|
78
|
+
html1.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
|
|
79
|
+
body1.style.position = previousStyles.bodyPosition;
|
|
80
|
+
body1.style.top = previousStyles.bodyTop;
|
|
81
|
+
body1.style.width = previousStyles.bodyWidth;
|
|
82
|
+
body1.style.overflow = previousStyles.bodyOverflow;
|
|
83
|
+
body1.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
|
|
84
|
+
if (savedScrollY > 0) {
|
|
85
|
+
window.scrollTo(0, savedScrollY);
|
|
86
|
+
}
|
|
87
|
+
previousStyles = null;
|
|
88
|
+
savedScrollY = 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, [enabled]);
|
|
92
|
+
(0, import_react.useEffect)(function() {
|
|
93
|
+
return function() {
|
|
94
|
+
if (wasEnabled.current) {
|
|
95
|
+
wasEnabled.current = false;
|
|
96
|
+
if (--refCount === 0 && previousStyles) {
|
|
97
|
+
var html = document.documentElement;
|
|
98
|
+
var body = document.body;
|
|
99
|
+
html.style.overflow = previousStyles.htmlOverflow;
|
|
100
|
+
html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
|
|
101
|
+
body.style.position = previousStyles.bodyPosition;
|
|
102
|
+
body.style.top = previousStyles.bodyTop;
|
|
103
|
+
body.style.width = previousStyles.bodyWidth;
|
|
104
|
+
body.style.overflow = previousStyles.bodyOverflow;
|
|
105
|
+
body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
|
|
106
|
+
if (savedScrollY > 0) {
|
|
107
|
+
window.scrollTo(0, savedScrollY);
|
|
108
|
+
}
|
|
109
|
+
previousStyles = null;
|
|
110
|
+
savedScrollY = 0;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}, []);
|
|
118
115
|
};
|
|
116
|
+
|
|
119
117
|
//# sourceMappingURL=useDisableScroll.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useDisableScroll.native.js","names":[],"sources":["cjs/useDisableScroll.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar useDisableScroll_exports = {};\n__export(useDisableScroll_exports, {\n useDisableBodyScroll: () => useDisableBodyScroll\n});\nmodule.exports = __toCommonJS(useDisableScroll_exports);\nvar import_react = require(\"react\");\nvar canUseDOM = function() {\n return typeof window !== \"undefined\" && !!window.document && !!window.document.createElement;\n};\nvar refCount = 0;\nvar savedScrollY = 0;\nvar previousStyles = null;\nfunction isIOSSafari() {\n if (typeof navigator === \"undefined\") return false;\n var ua = navigator.userAgent;\n var isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === \"MacIntel\" && navigator.maxTouchPoints > 1;\n var isSafari = /^((?!chrome|android).)*safari/i.test(ua);\n return isIOS && isSafari;\n}\nvar useDisableBodyScroll = function(enabled) {\n var wasEnabled = (0, import_react.useRef)(false);\n (0, import_react.useEffect)(function() {\n if (!canUseDOM()) {\n return;\n }\n if (enabled && !wasEnabled.current) {\n wasEnabled.current = true;\n if (++refCount === 1) {\n var html = document.documentElement;\n var body = document.body;\n savedScrollY = window.scrollY;\n previousStyles = {\n htmlOverflow: html.style.overflow,\n htmlScrollbarGutter: html.style.scrollbarGutter,\n bodyPosition: body.style.position,\n bodyTop: body.style.top,\n bodyWidth: body.style.width,\n bodyOverflow: body.style.overflow,\n bodyOverscrollBehavior: body.style.overscrollBehavior\n };\n html.style.scrollbarGutter = \"stable\";\n html.style.overflow = \"hidden\";\n body.style.overscrollBehavior = \"none\";\n if (isIOSSafari()) {\n body.style.position = \"fixed\";\n body.style.top = `-${savedScrollY}px`;\n body.style.width = \"100%\";\n body.style.overflow = \"hidden\";\n }\n }\n } else if (!enabled && wasEnabled.current) {\n wasEnabled.current = false;\n if (--refCount === 0 && previousStyles) {\n var html1 = document.documentElement;\n var body1 = document.body;\n html1.style.overflow = previousStyles.htmlOverflow;\n html1.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;\n body1.style.position = previousStyles.bodyPosition;\n body1.style.top = previousStyles.bodyTop;\n body1.style.width = previousStyles.bodyWidth;\n body1.style.overflow = previousStyles.bodyOverflow;\n body1.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;\n if (savedScrollY > 0) {\n window.scrollTo(0, savedScrollY);\n }\n previousStyles = null;\n savedScrollY = 0;\n }\n }\n }, [\n enabled\n ]);\n (0, import_react.useEffect)(function() {\n return function() {\n if (wasEnabled.current) {\n wasEnabled.current = false;\n if (--refCount === 0 && previousStyles) {\n var html = document.documentElement;\n var body = document.body;\n html.style.overflow = previousStyles.htmlOverflow;\n html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;\n body.style.position = previousStyles.bodyPosition;\n body.style.top = previousStyles.bodyTop;\n body.style.width = previousStyles.bodyWidth;\n body.style.overflow = previousStyles.bodyOverflow;\n body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;\n if (savedScrollY > 0) {\n window.scrollTo(0, savedScrollY);\n }\n previousStyles = null;\n savedScrollY = 0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AAG,aAAa,WAAW,WAAW;EACrC,OAAO,WAAW;GAChB,IAAI,WAAW,SAAS;IACtB,WAAW,UAAU;IACrB,IAAI,EAAE,aAAa,KAAK,gBAAgB;KACtC,IAAI,OAAO,SAAS;KACpB,IAAI,OAAO,SAAS;KACpB,KAAK,MAAM,WAAW,eAAe;KACrC,KAAK,MAAM,kBAAkB,eAAe;KAC5C,KAAK,MAAM,WAAW,eAAe;KACrC,KAAK,MAAM,MAAM,eAAe;KAChC,KAAK,MAAM,QAAQ,eAAe;KAClC,KAAK,MAAM,WAAW,eAAe;KACrC,KAAK,MAAM,qBAAqB,eAAe;KAC/C,IAAI,eAAe,GAAG;MACpB,OAAO,SAAS,GAAG,YAAY;KACjC;KACA,iBAAiB;KACjB,eAAe;IACjB;GACF;EACF;CACF,GAAG,CAAC,CAAC;AACP"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useDisableBodyScroll } from "./useDisableScroll.mjs";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
const RemoveScroll = (props) => {
|
|
4
|
+
useDisableBodyScroll(Boolean(props.enabled));
|
|
5
|
+
return props.children;
|
|
5
6
|
};
|
|
7
|
+
|
|
6
8
|
export { RemoveScroll };
|
|
7
9
|
//# sourceMappingURL=RemoveScroll.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"RemoveScroll.js","names":[],"sources":["esm/RemoveScroll.js"],"sourcesContent":["import { useDisableBodyScroll } from \"./useDisableScroll\";\nconst RemoveScroll = (props) => {\n useDisableBodyScroll(Boolean(props.enabled));\n return props.children;\n};\nexport {\n RemoveScroll\n};\n//# sourceMappingURL=RemoveScroll.js.map\n"],"mappings":";;;AACA,MAAM,gBAAgB,UAAU;CAC9B,qBAAqB,QAAQ,MAAM,OAAO,CAAC;CAC3C,OAAO,MAAM;AACf"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
var RemoveScroll = function
|
|
2
|
-
|
|
1
|
+
var RemoveScroll = function(props) {
|
|
2
|
+
return props.children;
|
|
3
3
|
};
|
|
4
|
-
var getAllowedScrollableNode = function
|
|
4
|
+
var getAllowedScrollableNode = function() {};
|
|
5
|
+
|
|
5
6
|
export { RemoveScroll, getAllowedScrollableNode };
|
|
6
7
|
//# sourceMappingURL=RemoveScroll.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"RemoveScroll.native.js","names":[],"sources":["esm/RemoveScroll.native.js"],"sourcesContent":["var RemoveScroll = function(props) {\n return props.children;\n};\nvar getAllowedScrollableNode = function() {\n};\nexport {\n RemoveScroll,\n getAllowedScrollableNode\n};\n//# sourceMappingURL=RemoveScroll.native.js.map\n"],"mappings":";AAAA,IAAI,eAAe,SAAS,OAAO;CACjC,OAAO,MAAM;AACf;AACA,IAAI,2BAA2B,WAAW,CAC1C"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./RemoveScroll.mjs"
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./RemoveScroll.mjs"
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./RemoveScroll.mjs"
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export * from "./RemoveScroll.mjs"
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./RemoveScroll.native.js"
|
|
2
|
-
//# sourceMappingURL=index.native.js.map
|
|
1
|
+
export * from "./RemoveScroll.native.js"
|
|
@@ -1,89 +1,91 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
|
+
|
|
2
3
|
const canUseDOM = () => typeof window !== "undefined" && !!window.document && !!window.document.createElement;
|
|
3
4
|
let refCount = 0;
|
|
4
5
|
let savedScrollY = 0;
|
|
5
6
|
let previousStyles = null;
|
|
6
7
|
function isIOSSafari() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
if (typeof navigator === "undefined") return false;
|
|
9
|
+
const ua = navigator.userAgent;
|
|
10
|
+
const isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
|
|
11
|
+
const isSafari = /^((?!chrome|android).)*safari/i.test(ua);
|
|
12
|
+
return isIOS && isSafari;
|
|
12
13
|
}
|
|
13
|
-
const useDisableBodyScroll = enabled => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
14
|
+
const useDisableBodyScroll = (enabled) => {
|
|
15
|
+
const wasEnabled = useRef(false);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!canUseDOM()) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (enabled && !wasEnabled.current) {
|
|
21
|
+
wasEnabled.current = true;
|
|
22
|
+
if (++refCount === 1) {
|
|
23
|
+
const html = document.documentElement;
|
|
24
|
+
const body = document.body;
|
|
25
|
+
savedScrollY = window.scrollY;
|
|
26
|
+
previousStyles = {
|
|
27
|
+
htmlOverflow: html.style.overflow,
|
|
28
|
+
htmlScrollbarGutter: html.style.scrollbarGutter,
|
|
29
|
+
bodyPosition: body.style.position,
|
|
30
|
+
bodyTop: body.style.top,
|
|
31
|
+
bodyWidth: body.style.width,
|
|
32
|
+
bodyOverflow: body.style.overflow,
|
|
33
|
+
bodyOverscrollBehavior: body.style.overscrollBehavior
|
|
34
|
+
};
|
|
35
|
+
html.style.scrollbarGutter = "stable";
|
|
36
|
+
html.style.overflow = "hidden";
|
|
37
|
+
body.style.overscrollBehavior = "none";
|
|
38
|
+
if (isIOSSafari()) {
|
|
39
|
+
body.style.position = "fixed";
|
|
40
|
+
body.style.top = `-${savedScrollY}px`;
|
|
41
|
+
body.style.width = "100%";
|
|
42
|
+
body.style.overflow = "hidden";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} else if (!enabled && wasEnabled.current) {
|
|
46
|
+
wasEnabled.current = false;
|
|
47
|
+
if (--refCount === 0 && previousStyles) {
|
|
48
|
+
const html = document.documentElement;
|
|
49
|
+
const body = document.body;
|
|
50
|
+
html.style.overflow = previousStyles.htmlOverflow;
|
|
51
|
+
html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
|
|
52
|
+
body.style.position = previousStyles.bodyPosition;
|
|
53
|
+
body.style.top = previousStyles.bodyTop;
|
|
54
|
+
body.style.width = previousStyles.bodyWidth;
|
|
55
|
+
body.style.overflow = previousStyles.bodyOverflow;
|
|
56
|
+
body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
|
|
57
|
+
if (savedScrollY > 0) {
|
|
58
|
+
window.scrollTo(0, savedScrollY);
|
|
59
|
+
}
|
|
60
|
+
previousStyles = null;
|
|
61
|
+
savedScrollY = 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, [enabled]);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
return () => {
|
|
67
|
+
if (wasEnabled.current) {
|
|
68
|
+
wasEnabled.current = false;
|
|
69
|
+
if (--refCount === 0 && previousStyles) {
|
|
70
|
+
const html = document.documentElement;
|
|
71
|
+
const body = document.body;
|
|
72
|
+
html.style.overflow = previousStyles.htmlOverflow;
|
|
73
|
+
html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
|
|
74
|
+
body.style.position = previousStyles.bodyPosition;
|
|
75
|
+
body.style.top = previousStyles.bodyTop;
|
|
76
|
+
body.style.width = previousStyles.bodyWidth;
|
|
77
|
+
body.style.overflow = previousStyles.bodyOverflow;
|
|
78
|
+
body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
|
|
79
|
+
if (savedScrollY > 0) {
|
|
80
|
+
window.scrollTo(0, savedScrollY);
|
|
81
|
+
}
|
|
82
|
+
previousStyles = null;
|
|
83
|
+
savedScrollY = 0;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}, []);
|
|
87
88
|
};
|
|
89
|
+
|
|
88
90
|
export { useDisableBodyScroll };
|
|
89
91
|
//# sourceMappingURL=useDisableScroll.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useDisableScroll.js","names":[],"sources":["esm/useDisableScroll.js"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nconst canUseDOM = () => typeof window !== \"undefined\" && !!window.document && !!window.document.createElement;\nlet refCount = 0;\nlet savedScrollY = 0;\nlet previousStyles = null;\nfunction isIOSSafari() {\n if (typeof navigator === \"undefined\") return false;\n const ua = navigator.userAgent;\n const isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === \"MacIntel\" && navigator.maxTouchPoints > 1;\n const isSafari = /^((?!chrome|android).)*safari/i.test(ua);\n return isIOS && isSafari;\n}\nconst useDisableBodyScroll = (enabled) => {\n const wasEnabled = useRef(false);\n useEffect(() => {\n if (!canUseDOM()) {\n return;\n }\n if (enabled && !wasEnabled.current) {\n wasEnabled.current = true;\n if (++refCount === 1) {\n const html = document.documentElement;\n const body = document.body;\n savedScrollY = window.scrollY;\n previousStyles = {\n htmlOverflow: html.style.overflow,\n htmlScrollbarGutter: html.style.scrollbarGutter,\n bodyPosition: body.style.position,\n bodyTop: body.style.top,\n bodyWidth: body.style.width,\n bodyOverflow: body.style.overflow,\n bodyOverscrollBehavior: body.style.overscrollBehavior\n };\n html.style.scrollbarGutter = \"stable\";\n html.style.overflow = \"hidden\";\n body.style.overscrollBehavior = \"none\";\n if (isIOSSafari()) {\n body.style.position = \"fixed\";\n body.style.top = `-${savedScrollY}px`;\n body.style.width = \"100%\";\n body.style.overflow = \"hidden\";\n }\n }\n } else if (!enabled && wasEnabled.current) {\n wasEnabled.current = false;\n if (--refCount === 0 && previousStyles) {\n const html = document.documentElement;\n const body = document.body;\n html.style.overflow = previousStyles.htmlOverflow;\n html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;\n body.style.position = previousStyles.bodyPosition;\n body.style.top = previousStyles.bodyTop;\n body.style.width = previousStyles.bodyWidth;\n body.style.overflow = previousStyles.bodyOverflow;\n body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;\n if (savedScrollY > 0) {\n window.scrollTo(0, savedScrollY);\n }\n previousStyles = null;\n savedScrollY = 0;\n }\n }\n }, [enabled]);\n useEffect(() => {\n return () => {\n if (wasEnabled.current) {\n wasEnabled.current = false;\n if (--refCount === 0 && previousStyles) {\n const html = document.documentElement;\n const body = document.body;\n html.style.overflow = previousStyles.htmlOverflow;\n html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;\n body.style.position = previousStyles.bodyPosition;\n body.style.top = previousStyles.bodyTop;\n body.style.width = previousStyles.bodyWidth;\n body.style.overflow = previousStyles.bodyOverflow;\n body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;\n if (savedScrollY > 0) {\n window.scrollTo(0, savedScrollY);\n }\n previousStyles = null;\n savedScrollY = 0;\n }\n }\n };\n }, []);\n};\nexport {\n useDisableBodyScroll\n};\n//# sourceMappingURL=useDisableScroll.js.map\n"],"mappings":";;;AACA,MAAM,kBAAkB,OAAO,WAAW,eAAe,CAAC,CAAC,OAAO,YAAY,CAAC,CAAC,OAAO,SAAS;AAChG,IAAI,WAAW;AACf,IAAI,eAAe;AACnB,IAAI,iBAAiB;AACrB,SAAS,cAAc;CACrB,IAAI,OAAO,cAAc,aAAa,OAAO;CAC7C,MAAM,KAAK,UAAU;CACrB,MAAM,QAAQ,mBAAmB,KAAK,EAAE,KAAK,UAAU,aAAa,cAAc,UAAU,iBAAiB;CAC7G,MAAM,WAAW,iCAAiC,KAAK,EAAE;CACzD,OAAO,SAAS;AAClB;AACA,MAAM,wBAAwB,YAAY;CACxC,MAAM,aAAa,OAAO,KAAK;CAC/B,gBAAgB;EACd,IAAI,CAAC,UAAU,GAAG;GAChB;EACF;EACA,IAAI,WAAW,CAAC,WAAW,SAAS;GAClC,WAAW,UAAU;GACrB,IAAI,EAAE,aAAa,GAAG;IACpB,MAAM,OAAO,SAAS;IACtB,MAAM,OAAO,SAAS;IACtB,eAAe,OAAO;IACtB,iBAAiB;KACf,cAAc,KAAK,MAAM;KACzB,qBAAqB,KAAK,MAAM;KAChC,cAAc,KAAK,MAAM;KACzB,SAAS,KAAK,MAAM;KACpB,WAAW,KAAK,MAAM;KACtB,cAAc,KAAK,MAAM;KACzB,wBAAwB,KAAK,MAAM;IACrC;IACA,KAAK,MAAM,kBAAkB;IAC7B,KAAK,MAAM,WAAW;IACtB,KAAK,MAAM,q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