@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.system.js
CHANGED
|
@@ -3829,9 +3829,18 @@ System.register('Utils', [], (function (exports) {
|
|
|
3829
3829
|
/** 使用的配置 */
|
|
3830
3830
|
api;
|
|
3831
3831
|
constructor(option) {
|
|
3832
|
+
if (option) {
|
|
3833
|
+
if (option.globalThis == null) {
|
|
3834
|
+
option.globalThis = option.window;
|
|
3835
|
+
}
|
|
3836
|
+
if (option.self == null) {
|
|
3837
|
+
option.self = option.window;
|
|
3838
|
+
}
|
|
3839
|
+
}
|
|
3832
3840
|
if (!option) {
|
|
3833
3841
|
option = Object.assign({}, this.defaultApi);
|
|
3834
3842
|
}
|
|
3843
|
+
// @ts-ignore
|
|
3835
3844
|
this.api = Object.assign({}, option);
|
|
3836
3845
|
}
|
|
3837
3846
|
get document() {
|
|
@@ -4096,7 +4105,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4096
4105
|
this.windowApi = new WindowApi(option);
|
|
4097
4106
|
}
|
|
4098
4107
|
/** 版本号 */
|
|
4099
|
-
version = "2024.11.
|
|
4108
|
+
version = "2024.11.6";
|
|
4100
4109
|
addStyle(cssText) {
|
|
4101
4110
|
if (typeof cssText !== "string") {
|
|
4102
4111
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5280,13 +5289,45 @@ System.register('Utils', [], (function (exports) {
|
|
|
5280
5289
|
isNativeFunc(target) {
|
|
5281
5290
|
return Boolean(target.toString().match(/^function .*\(\) { \[native code\] }$/));
|
|
5282
5291
|
}
|
|
5283
|
-
isNearBottom(
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
this.windowApi.
|
|
5288
|
-
|
|
5289
|
-
|
|
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
|
+
}
|
|
5290
5331
|
}
|
|
5291
5332
|
isDOM(target) {
|
|
5292
5333
|
return target instanceof Node;
|