@tamagui/remove-scroll 3.0.0-beta.924.1 → 3.0.0
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/useDisableScroll.cjs +3 -1
- package/dist/cjs/useDisableScroll.native.cjs +3 -1
- package/dist/cjs/useDisableScroll.native.js +3 -1
- package/dist/cjs/useDisableScroll.native.js.map +1 -1
- package/dist/esm/useDisableScroll.mjs +3 -1
- package/dist/esm/useDisableScroll.mjs.map +1 -1
- package/dist/esm/useDisableScroll.native.js +3 -1
- package/dist/esm/useDisableScroll.native.js.map +1 -1
- package/dist/jsx/useDisableScroll.mjs +3 -1
- package/dist/jsx/useDisableScroll.mjs.map +1 -1
- package/dist/jsx/useDisableScroll.native.cjs +3 -1
- package/dist/jsx/useDisableScroll.native.js +3 -1
- package/dist/jsx/useDisableScroll.native.js.map +1 -1
- package/package.json +5 -3
- package/src/useDisableScroll.ts +5 -2
- package/types/useDisableScroll.d.ts.map +1 -1
|
@@ -54,7 +54,9 @@ const useDisableBodyScroll = (enabled) => {
|
|
|
54
54
|
bodyOverflow: body.style.overflow,
|
|
55
55
|
bodyOverscrollBehavior: body.style.overscrollBehavior
|
|
56
56
|
};
|
|
57
|
-
html.
|
|
57
|
+
if (window.innerWidth > html.clientWidth) {
|
|
58
|
+
html.style.scrollbarGutter = "stable";
|
|
59
|
+
}
|
|
58
60
|
html.style.overflow = "hidden";
|
|
59
61
|
body.style.overscrollBehavior = "none";
|
|
60
62
|
if (isIOSSafari()) {
|
|
@@ -58,7 +58,9 @@ var useDisableBodyScroll = function(enabled) {
|
|
|
58
58
|
bodyOverflow: body.style.overflow,
|
|
59
59
|
bodyOverscrollBehavior: body.style.overscrollBehavior
|
|
60
60
|
};
|
|
61
|
-
html.
|
|
61
|
+
if (window.innerWidth > html.clientWidth) {
|
|
62
|
+
html.style.scrollbarGutter = "stable";
|
|
63
|
+
}
|
|
62
64
|
html.style.overflow = "hidden";
|
|
63
65
|
body.style.overscrollBehavior = "none";
|
|
64
66
|
if (isIOSSafari()) {
|
|
@@ -58,7 +58,9 @@ var useDisableBodyScroll = function(enabled) {
|
|
|
58
58
|
bodyOverflow: body.style.overflow,
|
|
59
59
|
bodyOverscrollBehavior: body.style.overscrollBehavior
|
|
60
60
|
};
|
|
61
|
-
html.
|
|
61
|
+
if (window.innerWidth > html.clientWidth) {
|
|
62
|
+
html.style.scrollbarGutter = "stable";
|
|
63
|
+
}
|
|
62
64
|
html.style.overflow = "hidden";
|
|
63
65
|
body.style.overscrollBehavior = "none";
|
|
64
66
|
if (isIOSSafari()) {
|
|
@@ -1 +1 @@
|
|
|
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;\n }\n }\n };\n }, []);\n};\n//# sourceMappingURL=useDisableScroll.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,2BAA2B,CAAC;AAChC,SAAS,0BAA0B,EACjC,4BAA4B,qBAC9B,CAAC;AACD,OAAO,UAAU,aAAa,wBAAwB;AACtD,IAAI,eAAe,QAAQ,OAAO;AAClC,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,cAAc,GAAG,aAAa,OAAM,CAAE,KAAK;CAC/C,CAAC,GAAG,aAAa,UAAS,CAAE,WAAW;EACrC,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,KAAK,MAAM,kBAAkB;
|
|
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 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 (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;\n }\n }\n };\n }, []);\n};\n//# sourceMappingURL=useDisableScroll.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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CAAC;AACP"}
|
|
@@ -32,7 +32,9 @@ const useDisableBodyScroll = (enabled) => {
|
|
|
32
32
|
bodyOverflow: body.style.overflow,
|
|
33
33
|
bodyOverscrollBehavior: body.style.overscrollBehavior
|
|
34
34
|
};
|
|
35
|
-
html.
|
|
35
|
+
if (window.innerWidth > html.clientWidth) {
|
|
36
|
+
html.style.scrollbarGutter = "stable";
|
|
37
|
+
}
|
|
36
38
|
html.style.overflow = "hidden";
|
|
37
39
|
body.style.overscrollBehavior = "none";
|
|
38
40
|
if (isIOSSafari()) {
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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 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 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,IAA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M,QAAQ,eAAe;IAClC,KAAK,MAAM,WAAW,eAAe;IACrC,KAAK,MAAM,qBAAqB,eAAe;IAC/C,IAAI,eAAe,GAAG;KACpB,OAAO,SAAS,GAAG,YAAY;IACjC;IACA,iBAAiB;IACjB,eAAe;GACjB;EACF;CACF,GAAG,CAAC,OAAO,CAAC;CACZ,gBAAgB;EACd,aAAa;GACX,IAAI,WAAW,SAAS;IACtB,WAAW,UAAU;IACrB,IAAI,EAAE,aAAa,KAAK,gBAAgB;KACtC,MAAM,OAAO,SAAS;KACtB,MAAM,OAAO,SAAS;KACtB,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"}
|
|
@@ -34,7 +34,9 @@ var useDisableBodyScroll = function(enabled) {
|
|
|
34
34
|
bodyOverflow: body.style.overflow,
|
|
35
35
|
bodyOverscrollBehavior: body.style.overscrollBehavior
|
|
36
36
|
};
|
|
37
|
-
html.
|
|
37
|
+
if (window.innerWidth > html.clientWidth) {
|
|
38
|
+
html.style.scrollbarGutter = "stable";
|
|
39
|
+
}
|
|
38
40
|
html.style.overflow = "hidden";
|
|
39
41
|
body.style.overscrollBehavior = "none";
|
|
40
42
|
if (isIOSSafari()) {
|
|
@@ -1 +1 @@
|
|
|
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 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 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,KAAK,MAAM,kBAAkB;
|
|
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,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,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"}
|
|
@@ -32,7 +32,9 @@ const useDisableBodyScroll = (enabled) => {
|
|
|
32
32
|
bodyOverflow: body.style.overflow,
|
|
33
33
|
bodyOverscrollBehavior: body.style.overscrollBehavior
|
|
34
34
|
};
|
|
35
|
-
html.
|
|
35
|
+
if (window.innerWidth > html.clientWidth) {
|
|
36
|
+
html.style.scrollbarGutter = "stable";
|
|
37
|
+
}
|
|
36
38
|
html.style.overflow = "hidden";
|
|
37
39
|
body.style.overscrollBehavior = "none";
|
|
38
40
|
if (isIOSSafari()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDisableScroll.js","names":[],"sources":["jsx/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;
|
|
1
|
+
{"version":3,"file":"useDisableScroll.js","names":[],"sources":["jsx/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 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 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,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,MAAM,OAAO,SAAS;IACtB,MAAM,OAAO,SAAS;IACtB,KAAK,MAAM,WAAW,eAAe;IACrC,KAAK,MAAM,kBAAkB,eAAe;IAC5C,KAAK,MAAM,WAAW,eAAe;IACrC,KAAK,MAAM,MAAM,eAAe;IAChC,KAAK,MAAM,QAAQ,eAAe;IAClC,KAAK,MAAM,WAAW,eAAe;IACrC,KAAK,MAAM,qBAAqB,eAAe;IAC/C,IAAI,eAAe,GAAG;KACpB,OAAO,SAAS,GAAG,YAAY;IACjC;IACA,iBAAiB;IACjB,eAAe;GACjB;EACF;CACF,GAAG,CAAC,OAAO,CAAC;CACZ,gBAAgB;EACd,aAAa;GACX,IAAI,WAAW,SAAS;IACtB,WAAW,UAAU;IACrB,IAAI,EAAE,aAAa,KAAK,gBAAgB;KACtC,MAAM,OAAO,SAAS;KACtB,MAAM,OAAO,SAAS;KACtB,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"}
|
|
@@ -58,7 +58,9 @@ var useDisableBodyScroll = function(enabled) {
|
|
|
58
58
|
bodyOverflow: body.style.overflow,
|
|
59
59
|
bodyOverscrollBehavior: body.style.overscrollBehavior
|
|
60
60
|
};
|
|
61
|
-
html.
|
|
61
|
+
if (window.innerWidth > html.clientWidth) {
|
|
62
|
+
html.style.scrollbarGutter = "stable";
|
|
63
|
+
}
|
|
62
64
|
html.style.overflow = "hidden";
|
|
63
65
|
body.style.overscrollBehavior = "none";
|
|
64
66
|
if (isIOSSafari()) {
|
|
@@ -58,7 +58,9 @@ var useDisableBodyScroll = function(enabled) {
|
|
|
58
58
|
bodyOverflow: body.style.overflow,
|
|
59
59
|
bodyOverscrollBehavior: body.style.overscrollBehavior
|
|
60
60
|
};
|
|
61
|
-
html.
|
|
61
|
+
if (window.innerWidth > html.clientWidth) {
|
|
62
|
+
html.style.scrollbarGutter = "stable";
|
|
63
|
+
}
|
|
62
64
|
html.style.overflow = "hidden";
|
|
63
65
|
body.style.overscrollBehavior = "none";
|
|
64
66
|
if (isIOSSafari()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDisableScroll.native.js","names":[],"sources":["jsx/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;\n }\n }\n };\n }, []);\n};\n//# sourceMappingURL=useDisableScroll.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,2BAA2B,CAAC;AAChC,SAAS,0BAA0B,EACjC,4BAA4B,qBAC9B,CAAC;AACD,OAAO,UAAU,aAAa,wBAAwB;AACtD,IAAI,eAAe,QAAQ,OAAO;AAClC,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,cAAc,GAAG,aAAa,OAAM,CAAE,KAAK;CAC/C,CAAC,GAAG,aAAa,UAAS,CAAE,WAAW;EACrC,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,KAAK,MAAM,kBAAkB;
|
|
1
|
+
{"version":3,"file":"useDisableScroll.native.js","names":[],"sources":["jsx/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 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 (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;\n }\n }\n };\n }, []);\n};\n//# sourceMappingURL=useDisableScroll.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,IA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AAiB;KACjB,eAAe;IACjB;GACF;EACF;CACF,GAAG,CAAC,CAAC;AACP"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/remove-scroll",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"files": [
|
|
5
6
|
"src",
|
|
6
7
|
"types",
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"clean:build": "tamagui-build clean:build"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@tamagui/build": "3.0.0
|
|
37
|
+
"@tamagui/build": "3.0.0",
|
|
37
38
|
"react": "19.2.3"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
@@ -44,5 +45,6 @@
|
|
|
44
45
|
"type": "git",
|
|
45
46
|
"url": "git+https://github.com/tamagui/tamagui.git",
|
|
46
47
|
"directory": "code/ui/remove-scroll"
|
|
47
|
-
}
|
|
48
|
+
},
|
|
49
|
+
"releaseSourceCommit": "15fbca480b143f876f6975601e23a17d3f90d2ee"
|
|
48
50
|
}
|
package/src/useDisableScroll.ts
CHANGED
|
@@ -55,8 +55,11 @@ export const useDisableBodyScroll = (enabled: boolean): void => {
|
|
|
55
55
|
bodyOverscrollBehavior: body.style.overscrollBehavior,
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
//
|
|
59
|
-
|
|
58
|
+
// keep the gutter only where a scrollbar was: reserving one on a page
|
|
59
|
+
// that had none shifts the content by the scrollbar width on every open
|
|
60
|
+
if (window.innerWidth > html.clientWidth) {
|
|
61
|
+
html.style.scrollbarGutter = 'stable'
|
|
62
|
+
}
|
|
60
63
|
html.style.overflow = 'hidden'
|
|
61
64
|
|
|
62
65
|
// prevent scroll chaining on all browsers
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"import { useEffect, useRef } from 'react'\n\nconst canUseDOM = () =>\n typeof window !== 'undefined' && !!window.document && !!window.document.createElement\n\nlet refCount = 0\nlet savedScrollY = 0\nlet previousStyles: {\n htmlOverflow: string\n htmlScrollbarGutter: string\n bodyPosition: string\n bodyTop: string\n bodyWidth: string\n bodyOverflow: string\n bodyOverscrollBehavior: string\n} | null = null\n\n// detect iOS Safari which needs position:fixed workaround\nfunction isIOSSafari() {\n if (typeof navigator === 'undefined') return false\n const ua = navigator.userAgent\n const isIOS =\n /iPad|iPhone|iPod/.test(ua) ||\n (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)\n const isSafari = /^((?!chrome|android).)*safari/i.test(ua)\n return isIOS && isSafari\n}\n\nexport const useDisableBodyScroll = (enabled: boolean): void => {\n const wasEnabled = useRef(false)\n\n useEffect(() => {\n if (!canUseDOM()) {\n return\n }\n\n if (enabled && !wasEnabled.current) {\n wasEnabled.current = true\n\n if (++refCount === 1) {\n const html = document.documentElement\n const body = document.body\n\n // save current scroll position before locking\n savedScrollY = window.scrollY\n\n // save previous styles\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\n //
|
|
9
|
+
"import { useEffect, useRef } from 'react'\n\nconst canUseDOM = () =>\n typeof window !== 'undefined' && !!window.document && !!window.document.createElement\n\nlet refCount = 0\nlet savedScrollY = 0\nlet previousStyles: {\n htmlOverflow: string\n htmlScrollbarGutter: string\n bodyPosition: string\n bodyTop: string\n bodyWidth: string\n bodyOverflow: string\n bodyOverscrollBehavior: string\n} | null = null\n\n// detect iOS Safari which needs position:fixed workaround\nfunction isIOSSafari() {\n if (typeof navigator === 'undefined') return false\n const ua = navigator.userAgent\n const isIOS =\n /iPad|iPhone|iPod/.test(ua) ||\n (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)\n const isSafari = /^((?!chrome|android).)*safari/i.test(ua)\n return isIOS && isSafari\n}\n\nexport const useDisableBodyScroll = (enabled: boolean): void => {\n const wasEnabled = useRef(false)\n\n useEffect(() => {\n if (!canUseDOM()) {\n return\n }\n\n if (enabled && !wasEnabled.current) {\n wasEnabled.current = true\n\n if (++refCount === 1) {\n const html = document.documentElement\n const body = document.body\n\n // save current scroll position before locking\n savedScrollY = window.scrollY\n\n // save previous styles\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\n // keep the gutter only where a scrollbar was: reserving one on a page\n // that had none shifts the content by the scrollbar width on every open\n if (window.innerWidth > html.clientWidth) {\n html.style.scrollbarGutter = 'stable'\n }\n html.style.overflow = 'hidden'\n\n // prevent scroll chaining on all browsers\n body.style.overscrollBehavior = 'none'\n\n // for iOS Safari, use position:fixed workaround\n // this also helps with any edge cases on other mobile browsers\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\n if (--refCount === 0 && previousStyles) {\n const html = document.documentElement\n const body = document.body\n\n // restore previous styles\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\n // restore scroll position (browsers reset to 0 when overflow:hidden is removed)\n if (savedScrollY > 0) {\n window.scrollTo(0, savedScrollY)\n }\n\n previousStyles = null\n savedScrollY = 0\n }\n }\n }, [enabled])\n\n // cleanup on unmount\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\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\n if (savedScrollY > 0) {\n window.scrollTo(0, savedScrollY)\n }\n\n previousStyles = null\n savedScrollY = 0\n }\n }\n }\n }, [])\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|