@whitesev/utils 2.11.9 → 2.11.11

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.
@@ -371,7 +371,7 @@ declare class Utils {
371
371
  x: number;
372
372
  y: number;
373
373
  }>>, deviation?: number): {
374
- /** 处理了偏移量后的z-index值 */
374
+ /** 处理了偏移量和阈值比较后的z-index值 */
375
375
  zIndex: number;
376
376
  /** 原始z-index值 */
377
377
  originZIndex: number;
@@ -393,7 +393,7 @@ declare class Utils {
393
393
  * Utils.getMaxZIndexNodeInfoFromPoint(20);
394
394
  */
395
395
  getMaxZIndexNodeInfoFromPoint(deviation: IFunction<number>): {
396
- /** 处理了偏移量后的z-index值 */
396
+ /** 处理了偏移量和阈值比较后的z-index值 */
397
397
  zIndex: number;
398
398
  /** 原始z-index值 */
399
399
  originZIndex: number;
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.9",
4
+ "version": "2.11.11",
5
5
  "description": "一个常用的工具库",
6
6
  "keywords": [
7
7
  "ScriptCat",
package/src/Utils.ts CHANGED
@@ -906,7 +906,7 @@ class Utils {
906
906
  $el?: IFunction<IArray<HTMLElement> | IArray<{ x: number; y: number }>>,
907
907
  deviation?: number
908
908
  ): {
909
- /** 处理了偏移量后的z-index值 */
909
+ /** 处理了偏移量和阈值比较后的z-index值 */
910
910
  zIndex: number;
911
911
  /** 原始z-index值 */
912
912
  originZIndex: number;
@@ -928,7 +928,7 @@ class Utils {
928
928
  * Utils.getMaxZIndexNodeInfoFromPoint(20);
929
929
  */
930
930
  getMaxZIndexNodeInfoFromPoint(deviation: IFunction<number>): {
931
- /** 处理了偏移量后的z-index值 */
931
+ /** 处理了偏移量和阈值比较后的z-index值 */
932
932
  zIndex: number;
933
933
  /** 原始z-index值 */
934
934
  originZIndex: number;
@@ -945,7 +945,7 @@ class Utils {
945
945
  $el?: IFunction<IArray<HTMLElement> | number | IArray<{ x: number; y: number }>>,
946
946
  deviation?: number
947
947
  ): {
948
- /** 处理了偏移量后的z-index值 */
948
+ /** 处理了偏移量和阈值比较后的z-index值 */
949
949
  zIndex: number;
950
950
  /** 原始z-index值 */
951
951
  originZIndex: number;
@@ -968,6 +968,10 @@ class Utils {
968
968
  if (typeof deviation !== "number" || Number.isNaN(deviation)) {
969
969
  deviation = 10;
970
970
  }
971
+ // 最大值 2147483647
972
+ // const maxZIndex = Math.pow(2, 31) - 1;
973
+ // 比较值 2000000000
974
+ const maxZIndexCompare = 2 * Math.pow(10, 9);
971
975
  /** 坐标偏移 */
972
976
  const positionDistance = 10;
973
977
  const defaultCalcPostion: {
@@ -1062,9 +1066,15 @@ class Utils {
1062
1066
  left: maxRect.left,
1063
1067
  };
1064
1068
  }
1069
+ const calcZIndex = zIndex + deviation;
1070
+ if (calcZIndex >= maxZIndexCompare) {
1071
+ // 不要超过最大值
1072
+ // 超过就忽略
1073
+ return;
1074
+ }
1065
1075
  return {
1066
1076
  /** 计算偏移量后的z-index值 */
1067
- zIndex: zIndex + deviation,
1077
+ zIndex: calcZIndex,
1068
1078
  /** 获取到的最大的z-index值 */
1069
1079
  originZIndex: zIndex,
1070
1080
  /** 拥有最大z-index的元素 */