@whitesev/utils 2.4.6 → 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 +49 -8
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +49 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +49 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +49 -8
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +49 -8
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +49 -8
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Utils.d.ts +11 -5
- package/dist/types/src/WindowApi.d.ts +2 -2
- package/dist/types/src/types/WindowApi.d.ts +3 -3
- package/package.json +1 -1
- package/src/Utils.ts +59 -16
- package/src/WindowApi.ts +13 -4
- package/src/types/WindowApi.d.ts +3 -3
package/dist/index.amd.js
CHANGED
|
@@ -3826,9 +3826,18 @@ define((function () { 'use strict';
|
|
|
3826
3826
|
/** 使用的配置 */
|
|
3827
3827
|
api;
|
|
3828
3828
|
constructor(option) {
|
|
3829
|
+
if (option) {
|
|
3830
|
+
if (option.globalThis == null) {
|
|
3831
|
+
option.globalThis = option.window;
|
|
3832
|
+
}
|
|
3833
|
+
if (option.self == null) {
|
|
3834
|
+
option.self = option.window;
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3829
3837
|
if (!option) {
|
|
3830
3838
|
option = Object.assign({}, this.defaultApi);
|
|
3831
3839
|
}
|
|
3840
|
+
// @ts-ignore
|
|
3832
3841
|
this.api = Object.assign({}, option);
|
|
3833
3842
|
}
|
|
3834
3843
|
get document() {
|
|
@@ -4093,7 +4102,7 @@ define((function () { 'use strict';
|
|
|
4093
4102
|
this.windowApi = new WindowApi(option);
|
|
4094
4103
|
}
|
|
4095
4104
|
/** 版本号 */
|
|
4096
|
-
version = "2024.11.
|
|
4105
|
+
version = "2024.11.6";
|
|
4097
4106
|
addStyle(cssText) {
|
|
4098
4107
|
if (typeof cssText !== "string") {
|
|
4099
4108
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5277,13 +5286,45 @@ define((function () { 'use strict';
|
|
|
5277
5286
|
isNativeFunc(target) {
|
|
5278
5287
|
return Boolean(target.toString().match(/^function .*\(\) { \[native code\] }$/));
|
|
5279
5288
|
}
|
|
5280
|
-
isNearBottom(
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
this.windowApi.
|
|
5285
|
-
|
|
5286
|
-
|
|
5289
|
+
isNearBottom(...args) {
|
|
5290
|
+
let nearBottomHeight = 50;
|
|
5291
|
+
let checkWindow = () => {
|
|
5292
|
+
// 已滚动的距离
|
|
5293
|
+
let scrollTop = this.windowApi.window.pageYOffset ||
|
|
5294
|
+
this.windowApi.document.documentElement.scrollTop;
|
|
5295
|
+
// 视窗高度
|
|
5296
|
+
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
5297
|
+
this.windowApi.document.documentElement.clientHeight;
|
|
5298
|
+
// 最大滚动距离
|
|
5299
|
+
let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
|
|
5300
|
+
return scrollTop + viewportHeight >= maxScrollHeight;
|
|
5301
|
+
};
|
|
5302
|
+
let checkNode = ($ele) => {
|
|
5303
|
+
// 已滚动的距离
|
|
5304
|
+
let scrollTop = $ele.scrollTop;
|
|
5305
|
+
// 视窗高度
|
|
5306
|
+
let viewportHeight = $ele.clientHeight;
|
|
5307
|
+
// 最大滚动距离
|
|
5308
|
+
let maxScrollHeight = $ele.scrollHeight - viewportHeight - nearBottomHeight;
|
|
5309
|
+
return scrollTop >= maxScrollHeight;
|
|
5310
|
+
};
|
|
5311
|
+
let firstArg = args[0];
|
|
5312
|
+
if (args.length === 0 || typeof args[0] === "number") {
|
|
5313
|
+
// nearBottomHeight
|
|
5314
|
+
//
|
|
5315
|
+
return checkWindow();
|
|
5316
|
+
}
|
|
5317
|
+
else if (typeof args[0] === "object" && args[0] instanceof HTMLElement) {
|
|
5318
|
+
// target
|
|
5319
|
+
// target,nearBottomHeight
|
|
5320
|
+
if (typeof args[1] === "number" && !Number.isNaN(args[1])) {
|
|
5321
|
+
nearBottomHeight = args[1];
|
|
5322
|
+
}
|
|
5323
|
+
return checkNode(args[0]);
|
|
5324
|
+
}
|
|
5325
|
+
else {
|
|
5326
|
+
throw new TypeError("参数1类型错误" + typeof firstArg);
|
|
5327
|
+
}
|
|
5287
5328
|
}
|
|
5288
5329
|
isDOM(target) {
|
|
5289
5330
|
return target instanceof Node;
|