@tamagui/remove-scroll 2.7.7 → 3.0.0-beta.1093.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 +17 -21
- package/dist/cjs/RemoveScroll.native.cjs +32 -0
- package/dist/cjs/RemoveScroll.native.js +18 -19
- package/dist/cjs/RemoveScroll.native.js.map +1 -1
- package/dist/cjs/index.cjs +9 -11
- package/dist/cjs/index.native.cjs +20 -0
- package/dist/cjs/index.native.js +9 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/useDisableScroll.cjs +95 -97
- package/dist/cjs/useDisableScroll.native.cjs +116 -0
- package/dist/cjs/useDisableScroll.native.js +97 -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 +83 -79
- package/dist/esm/useDisableScroll.mjs.map +1 -1
- package/dist/esm/useDisableScroll.native.js +85 -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 +32 -0
- package/dist/jsx/RemoveScroll.native.js +18 -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 +20 -0
- package/dist/jsx/index.native.js +9 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/useDisableScroll.mjs +83 -79
- package/dist/jsx/useDisableScroll.mjs.map +1 -1
- package/dist/jsx/useDisableScroll.native.cjs +116 -0
- package/dist/jsx/useDisableScroll.native.js +97 -98
- package/dist/jsx/useDisableScroll.native.js.map +1 -1
- package/package.json +4 -3
- package/src/useDisableScroll.ts +5 -2
- package/types/useDisableScroll.d.ts.map +1 -1
- 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,91 +1,95 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
var canUseDOM = function() {
|
|
4
|
+
return typeof window !== "undefined" && !!window.document && !!window.document.createElement;
|
|
4
5
|
};
|
|
5
6
|
var refCount = 0;
|
|
6
7
|
var savedScrollY = 0;
|
|
7
8
|
var previousStyles = null;
|
|
8
9
|
function isIOSSafari() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
if (typeof navigator === "undefined") return false;
|
|
11
|
+
var ua = navigator.userAgent;
|
|
12
|
+
var isIOS = /iPad|iPhone|iPod/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
|
|
13
|
+
var isSafari = /^((?!chrome|android).)*safari/i.test(ua);
|
|
14
|
+
return isIOS && isSafari;
|
|
14
15
|
}
|
|
15
|
-
var useDisableBodyScroll = function
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
16
|
+
var useDisableBodyScroll = function(enabled) {
|
|
17
|
+
var wasEnabled = useRef(false);
|
|
18
|
+
useEffect(function() {
|
|
19
|
+
if (!canUseDOM()) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (enabled && !wasEnabled.current) {
|
|
23
|
+
wasEnabled.current = true;
|
|
24
|
+
if (++refCount === 1) {
|
|
25
|
+
var html = document.documentElement;
|
|
26
|
+
var body = document.body;
|
|
27
|
+
savedScrollY = window.scrollY;
|
|
28
|
+
previousStyles = {
|
|
29
|
+
htmlOverflow: html.style.overflow,
|
|
30
|
+
htmlScrollbarGutter: html.style.scrollbarGutter,
|
|
31
|
+
bodyPosition: body.style.position,
|
|
32
|
+
bodyTop: body.style.top,
|
|
33
|
+
bodyWidth: body.style.width,
|
|
34
|
+
bodyOverflow: body.style.overflow,
|
|
35
|
+
bodyOverscrollBehavior: body.style.overscrollBehavior
|
|
36
|
+
};
|
|
37
|
+
if (window.innerWidth > html.clientWidth) {
|
|
38
|
+
html.style.scrollbarGutter = "stable";
|
|
39
|
+
}
|
|
40
|
+
html.style.overflow = "hidden";
|
|
41
|
+
body.style.overscrollBehavior = "none";
|
|
42
|
+
if (isIOSSafari()) {
|
|
43
|
+
body.style.position = "fixed";
|
|
44
|
+
body.style.top = `-${savedScrollY}px`;
|
|
45
|
+
body.style.width = "100%";
|
|
46
|
+
body.style.overflow = "hidden";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
} else if (!enabled && wasEnabled.current) {
|
|
50
|
+
wasEnabled.current = false;
|
|
51
|
+
if (--refCount === 0 && previousStyles) {
|
|
52
|
+
var html1 = document.documentElement;
|
|
53
|
+
var body1 = document.body;
|
|
54
|
+
html1.style.overflow = previousStyles.htmlOverflow;
|
|
55
|
+
html1.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
|
|
56
|
+
body1.style.position = previousStyles.bodyPosition;
|
|
57
|
+
body1.style.top = previousStyles.bodyTop;
|
|
58
|
+
body1.style.width = previousStyles.bodyWidth;
|
|
59
|
+
body1.style.overflow = previousStyles.bodyOverflow;
|
|
60
|
+
body1.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
|
|
61
|
+
if (savedScrollY > 0) {
|
|
62
|
+
window.scrollTo(0, savedScrollY);
|
|
63
|
+
}
|
|
64
|
+
previousStyles = null;
|
|
65
|
+
savedScrollY = 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}, [enabled]);
|
|
69
|
+
useEffect(function() {
|
|
70
|
+
return function() {
|
|
71
|
+
if (wasEnabled.current) {
|
|
72
|
+
wasEnabled.current = false;
|
|
73
|
+
if (--refCount === 0 && previousStyles) {
|
|
74
|
+
var html = document.documentElement;
|
|
75
|
+
var 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;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}, []);
|
|
89
92
|
};
|
|
93
|
+
|
|
90
94
|
export { useDisableBodyScroll };
|
|
91
95
|
//# sourceMappingURL=useDisableScroll.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useDisableScroll.native.js","names":[],"sources":["esm/useDisableScroll.native.js"],"sourcesContent":["import { useEffect, useRef } from \"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 = useRef(false);\n 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 if (window.innerWidth > html.clientWidth) {\n html.style.scrollbarGutter = \"stable\";\n }\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 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;\n }\n }\n };\n }, []);\n};\nexport {\n useDisableBodyScroll\n};\n//# sourceMappingURL=useDisableScroll.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,WAAW;CACzB,OAAO,OAAO,WAAW,eAAe,CAAC,CAAC,OAAO,YAAY,CAAC,CAAC,OAAO,SAAS;AACjF;AACA,IAAI,WAAW;AACf,IAAI,eAAe;AACnB,IAAI,iBAAiB;AACrB,SAAS,cAAc;CACrB,IAAI,OAAO,cAAc,aAAa,OAAO;CAC7C,IAAI,KAAK,UAAU;CACnB,IAAI,QAAQ,mBAAmB,KAAK,EAAE,KAAK,UAAU,aAAa,cAAc,UAAU,iBAAiB;CAC3G,IAAI,WAAW,iCAAiC,KAAK,EAAE;CACvD,OAAO,SAAS;AAClB;AACA,IAAI,uBAAuB,SAAS,SAAS;CAC3C,IAAI,aAAa,OAAO,KAAK;CAC7B,UAAU,WAAW;EACnB,IAAI,CAAC,UAAU,GAAG;GAChB;EACF;EACA,IAAI,WAAW,CAAC,WAAW,SAAS;GAClC,WAAW,UAAU;GACrB,IAAI,EAAE,aAAa,GAAG;IACpB,IAAI,OAAO,SAAS;IACpB,IAAI,OAAO,SAAS;IACpB,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,IAAI,OAAO,aAAa,KAAK,aAAa;KACxC,KAAK,MAAM,kBAAkB;IAC/B;IACA,KAAK,MAAM,WAAW;IACtB,KAAK,MAAM,qBAAqB;IAChC,IAAI,YAAY,GAAG;KACjB,KAAK,MAAM,WAAW;KACtB,KAAK,MAAM,MAAM,IAAI,aAAa;KAClC,KAAK,MAAM,QAAQ;KACnB,KAAK,MAAM,WAAW;IACxB;GACF;EACF,OAAO,IAAI,CAAC,WAAW,WAAW,SAAS;GACzC,WAAW,UAAU;GACrB,IAAI,EAAE,aAAa,KAAK,gBAAgB;IACtC,IAAI,QAAQ,SAAS;IACrB,IAAI,QAAQ,SAAS;IACrB,MAAM,MAAM,WAAW,eAAe;IACtC,MAAM,MAAM,kBAAkB,eAAe;IAC7C,MAAM,MAAM,WAAW,eAAe;IACtC,MAAM,MAAM,MAAM,eAAe;IACjC,MAAM,MAAM,QAAQ,eAAe;IACnC,MAAM,MAAM,WAAW,eAAe;IACtC,MAAM,MAAM,qBAAqB,eAAe;IAChD,IAAI,eAAe,GAAG;KACpB,OAAO,SAAS,GAAG,YAAY;IACjC;IACA,iBAAiB;IACjB,eAAe;GACjB;EACF;CACF,GAAG,CACD,OACF,CAAC;CACD,UAAU,WAAW;EACnB,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":["jsx/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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
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, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var RemoveScroll_native_exports = {};
|
|
24
|
+
__export(RemoveScroll_native_exports, {
|
|
25
|
+
RemoveScroll: () => RemoveScroll,
|
|
26
|
+
getAllowedScrollableNode: () => getAllowedScrollableNode
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(RemoveScroll_native_exports);
|
|
29
|
+
var RemoveScroll = function(props) {
|
|
30
|
+
return props.children;
|
|
31
|
+
};
|
|
32
|
+
var getAllowedScrollableNode = function() {};
|
|
@@ -5,31 +5,30 @@ 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
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
12
|
};
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
21
|
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
23
|
var RemoveScroll_native_exports = {};
|
|
26
24
|
__export(RemoveScroll_native_exports, {
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
RemoveScroll: () => RemoveScroll,
|
|
26
|
+
getAllowedScrollableNode: () => getAllowedScrollableNode
|
|
29
27
|
});
|
|
30
28
|
module.exports = __toCommonJS(RemoveScroll_native_exports);
|
|
31
|
-
var RemoveScroll = function
|
|
32
|
-
|
|
29
|
+
var RemoveScroll = function(props) {
|
|
30
|
+
return props.children;
|
|
33
31
|
};
|
|
34
|
-
var getAllowedScrollableNode = function
|
|
32
|
+
var getAllowedScrollableNode = function() {};
|
|
33
|
+
|
|
35
34
|
//# sourceMappingURL=RemoveScroll.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"RemoveScroll.native.js","names":[],"sources":["jsx/RemoveScroll.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 RemoveScroll_native_exports = {};\n__export(RemoveScroll_native_exports, {\n RemoveScroll: () => RemoveScroll,\n getAllowedScrollableNode: () => getAllowedScrollableNode\n});\nmodule.exports = __toCommonJS(RemoveScroll_native_exports);\nvar RemoveScroll = function(props) {\n return props.children;\n};\nvar getAllowedScrollableNode = function() {\n};\n//# sourceMappingURL=RemoveScroll.native.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,8BAA8B,CAAC;AACnC,SAAS,6BAA6B;CACpC,oBAAoB;CACpB,gCAAgC;AAClC,CAAC;AACD,OAAO,UAAU,aAAa,2BAA2B;AACzD,IAAI,eAAe,SAAS,OAAO;CACjC,OAAO,MAAM;AACf;AACA,IAAI,2BAA2B,WAAW,CAC1C"}
|
package/dist/jsx/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./RemoveScroll.mjs"
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./RemoveScroll.mjs"
|
package/dist/jsx/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./RemoveScroll.mjs"
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export * from "./RemoveScroll.mjs"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
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, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var index_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(index_exports);
|
|
20
|
+
__reExport(index_exports, require("./RemoveScroll.native.js"), module.exports);
|
package/dist/jsx/index.native.js
CHANGED
|
@@ -5,19 +5,18 @@ 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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
15
|
};
|
|
16
16
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
18
|
-
value: true
|
|
19
|
-
}), mod);
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
18
|
var index_exports = {};
|
|
21
19
|
module.exports = __toCommonJS(index_exports);
|
|
22
20
|
__reExport(index_exports, require("./RemoveScroll.native.js"), module.exports);
|
|
21
|
+
|
|
23
22
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["jsx/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./RemoveScroll\"), module.exports);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,cAAc,QAAQ,KAAK,kBAAkB,YAAY,QAAQ,KAAK,SAAS,GAAG,gBAAgB,YAAY,cAAc,KAAK,SAAS;AAC9I,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,0BAAgB,GAAG,OAAO,OAAO"}
|
|
@@ -1,89 +1,93 @@
|
|
|
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
|
+
if (window.innerWidth > html.clientWidth) {
|
|
36
|
+
html.style.scrollbarGutter = "stable";
|
|
37
|
+
}
|
|
38
|
+
html.style.overflow = "hidden";
|
|
39
|
+
body.style.overscrollBehavior = "none";
|
|
40
|
+
if (isIOSSafari()) {
|
|
41
|
+
body.style.position = "fixed";
|
|
42
|
+
body.style.top = `-${savedScrollY}px`;
|
|
43
|
+
body.style.width = "100%";
|
|
44
|
+
body.style.overflow = "hidden";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
} else if (!enabled && wasEnabled.current) {
|
|
48
|
+
wasEnabled.current = false;
|
|
49
|
+
if (--refCount === 0 && previousStyles) {
|
|
50
|
+
const html = document.documentElement;
|
|
51
|
+
const body = document.body;
|
|
52
|
+
html.style.overflow = previousStyles.htmlOverflow;
|
|
53
|
+
html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
|
|
54
|
+
body.style.position = previousStyles.bodyPosition;
|
|
55
|
+
body.style.top = previousStyles.bodyTop;
|
|
56
|
+
body.style.width = previousStyles.bodyWidth;
|
|
57
|
+
body.style.overflow = previousStyles.bodyOverflow;
|
|
58
|
+
body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
|
|
59
|
+
if (savedScrollY > 0) {
|
|
60
|
+
window.scrollTo(0, savedScrollY);
|
|
61
|
+
}
|
|
62
|
+
previousStyles = null;
|
|
63
|
+
savedScrollY = 0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}, [enabled]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
return () => {
|
|
69
|
+
if (wasEnabled.current) {
|
|
70
|
+
wasEnabled.current = false;
|
|
71
|
+
if (--refCount === 0 && previousStyles) {
|
|
72
|
+
const html = document.documentElement;
|
|
73
|
+
const body = document.body;
|
|
74
|
+
html.style.overflow = previousStyles.htmlOverflow;
|
|
75
|
+
html.style.scrollbarGutter = previousStyles.htmlScrollbarGutter;
|
|
76
|
+
body.style.position = previousStyles.bodyPosition;
|
|
77
|
+
body.style.top = previousStyles.bodyTop;
|
|
78
|
+
body.style.width = previousStyles.bodyWidth;
|
|
79
|
+
body.style.overflow = previousStyles.bodyOverflow;
|
|
80
|
+
body.style.overscrollBehavior = previousStyles.bodyOverscrollBehavior;
|
|
81
|
+
if (savedScrollY > 0) {
|
|
82
|
+
window.scrollTo(0, savedScrollY);
|
|
83
|
+
}
|
|
84
|
+
previousStyles = null;
|
|
85
|
+
savedScrollY = 0;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}, []);
|
|
87
90
|
};
|
|
91
|
+
|
|
88
92
|
export { useDisableBodyScroll };
|
|
89
93
|
//# sourceMappingURL=useDisableScroll.mjs.map
|