@whitesev/utils 2.4.7 → 2.4.8
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/index.amd.js +39 -7
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +39 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +39 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +39 -7
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +39 -7
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +39 -7
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Utils.d.ts +8 -2
- package/package.json +1 -1
- package/src/Utils.ts +54 -11
package/dist/index.umd.js
CHANGED
|
@@ -5290,13 +5290,45 @@
|
|
|
5290
5290
|
isNativeFunc(target) {
|
|
5291
5291
|
return Boolean(target.toString().match(/^function .*\(\) { \[native code\] }$/));
|
|
5292
5292
|
}
|
|
5293
|
-
isNearBottom(
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
this.windowApi.
|
|
5298
|
-
|
|
5299
|
-
|
|
5293
|
+
isNearBottom(...args) {
|
|
5294
|
+
let nearBottomHeight = 50;
|
|
5295
|
+
let checkWindow = () => {
|
|
5296
|
+
// 已滚动的距离
|
|
5297
|
+
let scrollTop = this.windowApi.window.pageYOffset ||
|
|
5298
|
+
this.windowApi.document.documentElement.scrollTop;
|
|
5299
|
+
// 视窗高度
|
|
5300
|
+
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
5301
|
+
this.windowApi.document.documentElement.clientHeight;
|
|
5302
|
+
// 最大滚动距离
|
|
5303
|
+
let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
|
|
5304
|
+
return scrollTop + viewportHeight >= maxScrollHeight;
|
|
5305
|
+
};
|
|
5306
|
+
let checkNode = ($ele) => {
|
|
5307
|
+
// 已滚动的距离
|
|
5308
|
+
let scrollTop = $ele.scrollTop;
|
|
5309
|
+
// 视窗高度
|
|
5310
|
+
let viewportHeight = $ele.clientHeight;
|
|
5311
|
+
// 最大滚动距离
|
|
5312
|
+
let maxScrollHeight = $ele.scrollHeight - viewportHeight - nearBottomHeight;
|
|
5313
|
+
return scrollTop >= maxScrollHeight;
|
|
5314
|
+
};
|
|
5315
|
+
let firstArg = args[0];
|
|
5316
|
+
if (args.length === 0 || typeof args[0] === "number") {
|
|
5317
|
+
// nearBottomHeight
|
|
5318
|
+
//
|
|
5319
|
+
return checkWindow();
|
|
5320
|
+
}
|
|
5321
|
+
else if (typeof args[0] === "object" && args[0] instanceof HTMLElement) {
|
|
5322
|
+
// target
|
|
5323
|
+
// target,nearBottomHeight
|
|
5324
|
+
if (typeof args[1] === "number" && !Number.isNaN(args[1])) {
|
|
5325
|
+
nearBottomHeight = args[1];
|
|
5326
|
+
}
|
|
5327
|
+
return checkNode(args[0]);
|
|
5328
|
+
}
|
|
5329
|
+
else {
|
|
5330
|
+
throw new TypeError("参数1类型错误" + typeof firstArg);
|
|
5331
|
+
}
|
|
5300
5332
|
}
|
|
5301
5333
|
isDOM(target) {
|
|
5302
5334
|
return target instanceof Node;
|