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