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