@sheinx/hooks 3.8.3 → 3.8.4-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/utils/document.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["document.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO;;;CASnB,CAAC;AACF,eAAO,MAAM,SAAS;;;CAmBrB,CAAC;AAEF,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,WAKvD"}
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["document.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO;;;CASnB,CAAC;AACF,eAAO,MAAM,SAAS;;;CAmBrB,CAAC;AAEF,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,WAKvD;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,WA6BzD"}
|
package/cjs/utils/document.js
CHANGED
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.docSize = exports.docScroll = void 0;
|
7
7
|
exports.isInDocument = isInDocument;
|
8
|
+
exports.isScrollAble = isScrollAble;
|
8
9
|
var _is = require("./is");
|
9
10
|
var docSize = exports.docSize = {
|
10
11
|
get width() {
|
@@ -41,4 +42,30 @@ function isInDocument(element) {
|
|
41
42
|
return element.isConnected;
|
42
43
|
}
|
43
44
|
return (0, _is.isBrowser)() && document.documentElement.contains(element);
|
45
|
+
}
|
46
|
+
function isScrollAble(container) {
|
47
|
+
if (!container || !(0, _is.isBrowser)()) return false;
|
48
|
+
if (container.scrollHeight > container.clientHeight) {
|
49
|
+
return true;
|
50
|
+
}
|
51
|
+
var placeholderEl = document.createElement('div');
|
52
|
+
placeholderEl.style.height = '9999px';
|
53
|
+
placeholderEl.style.top = '0';
|
54
|
+
placeholderEl.style.flexShrink = '0';
|
55
|
+
placeholderEl.style.left = '0';
|
56
|
+
placeholderEl.style.width = '1px';
|
57
|
+
placeholderEl.style.pointerEvents = 'none';
|
58
|
+
container.appendChild(placeholderEl);
|
59
|
+
var absoluteEl = document.createElement('div');
|
60
|
+
absoluteEl.style.position = 'absolute';
|
61
|
+
absoluteEl.style.top = '0';
|
62
|
+
absoluteEl.style.bottom = '0';
|
63
|
+
absoluteEl.style.left = '0';
|
64
|
+
absoluteEl.style.width = '1px';
|
65
|
+
absoluteEl.style.pointerEvents = 'none';
|
66
|
+
container.appendChild(absoluteEl);
|
67
|
+
var hasScroll = absoluteEl.clientHeight < placeholderEl.clientHeight;
|
68
|
+
placeholderEl.remove();
|
69
|
+
absoluteEl.remove();
|
70
|
+
return hasScroll;
|
44
71
|
}
|
package/esm/utils/document.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["document.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO;;;CASnB,CAAC;AACF,eAAO,MAAM,SAAS;;;CAmBrB,CAAC;AAEF,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,WAKvD"}
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["document.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO;;;CASnB,CAAC;AACF,eAAO,MAAM,SAAS;;;CAmBrB,CAAC;AAEF,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,WAKvD;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,WA6BzD"}
|
package/esm/utils/document.js
CHANGED
@@ -34,4 +34,30 @@ export function isInDocument(element) {
|
|
34
34
|
return element.isConnected;
|
35
35
|
}
|
36
36
|
return isBrowser() && document.documentElement.contains(element);
|
37
|
+
}
|
38
|
+
export function isScrollAble(container) {
|
39
|
+
if (!container || !isBrowser()) return false;
|
40
|
+
if (container.scrollHeight > container.clientHeight) {
|
41
|
+
return true;
|
42
|
+
}
|
43
|
+
var placeholderEl = document.createElement('div');
|
44
|
+
placeholderEl.style.height = '9999px';
|
45
|
+
placeholderEl.style.top = '0';
|
46
|
+
placeholderEl.style.flexShrink = '0';
|
47
|
+
placeholderEl.style.left = '0';
|
48
|
+
placeholderEl.style.width = '1px';
|
49
|
+
placeholderEl.style.pointerEvents = 'none';
|
50
|
+
container.appendChild(placeholderEl);
|
51
|
+
var absoluteEl = document.createElement('div');
|
52
|
+
absoluteEl.style.position = 'absolute';
|
53
|
+
absoluteEl.style.top = '0';
|
54
|
+
absoluteEl.style.bottom = '0';
|
55
|
+
absoluteEl.style.left = '0';
|
56
|
+
absoluteEl.style.width = '1px';
|
57
|
+
absoluteEl.style.pointerEvents = 'none';
|
58
|
+
container.appendChild(absoluteEl);
|
59
|
+
var hasScroll = absoluteEl.clientHeight < placeholderEl.clientHeight;
|
60
|
+
placeholderEl.remove();
|
61
|
+
absoluteEl.remove();
|
62
|
+
return hasScroll;
|
37
63
|
}
|