@whitesev/utils 2.11.6 → 2.11.7

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.
@@ -361,7 +361,7 @@ declare class Utils {
361
361
  * @param $el 仅检测目标元素最大的z-index(自动往上层找)
362
362
  * @param deviation 将对所有获取到的z-index处理偏移量(增加或减少),默认为10
363
363
  */
364
- getMaxZIndexNodeInfoFromPoint($el?: HTMLElement | HTMLElement[], deviation?: number): {
364
+ getMaxZIndexNodeInfoFromPoint($el?: IFunction<HTMLElement | HTMLElement[]>, deviation?: number): {
365
365
  /** 处理了偏移量后的z-index值 */
366
366
  zIndex: number;
367
367
  /** 原始z-index值 */
@@ -387,7 +387,7 @@ declare class Utils {
387
387
  * + 中间(宽: 1/2,高: 1/2)
388
388
  * @param deviation 将对所有获取到的z-index处理偏移量(增加或减少)
389
389
  */
390
- getMaxZIndexNodeInfoFromPoint(deviation: number): {
390
+ getMaxZIndexNodeInfoFromPoint(deviation: IFunction<number>): {
391
391
  /** 处理了偏移量后的z-index值 */
392
392
  zIndex: number;
393
393
  /** 原始z-index值 */
@@ -5,3 +5,7 @@ declare var unsafeWindow: Window;
5
5
  declare var mozIndexedDB: IDBFactory | null;
6
6
  declare var webkitIndexedDB: IDBFactory | null;
7
7
  declare var msIndexedDB: IDBFactory | null;
8
+
9
+ declare type IPromise<T> = T | Promise<T>;
10
+
11
+ declare type IFunction<T> = T | (() => T);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@whitesev/utils",
4
- "version": "2.11.6",
4
+ "version": "2.11.7",
5
5
  "description": "一个常用的工具库",
6
6
  "keywords": [
7
7
  "ScriptCat",
package/src/Utils.ts CHANGED
@@ -894,7 +894,7 @@ class Utils {
894
894
  * @param deviation 将对所有获取到的z-index处理偏移量(增加或减少),默认为10
895
895
  */
896
896
  getMaxZIndexNodeInfoFromPoint(
897
- $el?: HTMLElement | HTMLElement[],
897
+ $el?: IFunction<HTMLElement | HTMLElement[]>,
898
898
  deviation?: number
899
899
  ): {
900
900
  /** 处理了偏移量后的z-index值 */
@@ -922,7 +922,7 @@ class Utils {
922
922
  * + 中间(宽: 1/2,高: 1/2)
923
923
  * @param deviation 将对所有获取到的z-index处理偏移量(增加或减少)
924
924
  */
925
- getMaxZIndexNodeInfoFromPoint(deviation: number): {
925
+ getMaxZIndexNodeInfoFromPoint(deviation: IFunction<number>): {
926
926
  /** 处理了偏移量后的z-index值 */
927
927
  zIndex: number;
928
928
  /** 原始z-index值 */
@@ -937,7 +937,7 @@ class Utils {
937
937
  positionY: number;
938
938
  }[];
939
939
  getMaxZIndexNodeInfoFromPoint(
940
- $el?: HTMLElement | HTMLElement[] | number,
940
+ $el?: IFunction<HTMLElement | HTMLElement[] | number>,
941
941
  deviation?: number
942
942
  ): {
943
943
  /** 处理了偏移量后的z-index值 */
@@ -953,6 +953,9 @@ class Utils {
953
953
  /** y坐标 */
954
954
  positionY: number;
955
955
  }[] {
956
+ if (typeof $el === "function") {
957
+ $el = $el();
958
+ }
956
959
  if (typeof $el === "number") {
957
960
  deviation = $el;
958
961
  $el = void 0;
@@ -5,3 +5,7 @@ declare var unsafeWindow: Window;
5
5
  declare var mozIndexedDB: IDBFactory | null;
6
6
  declare var webkitIndexedDB: IDBFactory | null;
7
7
  declare var msIndexedDB: IDBFactory | null;
8
+
9
+ declare type IPromise<T> = T | Promise<T>;
10
+
11
+ declare type IFunction<T> = T | (() => T);