@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.
@@ -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(nearValue = 50) {
5293
- var scrollTop = this.windowApi.window.pageYOffset ||
5294
- this.windowApi.document.documentElement.scrollTop;
5295
- var windowHeight = this.windowApi.window.innerHeight ||
5296
- this.windowApi.document.documentElement.clientHeight;
5297
- var documentHeight = this.windowApi.document.documentElement.scrollHeight;
5298
- return scrollTop + windowHeight >= documentHeight - nearValue;
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;