@whitesev/pops 1.8.8 → 1.9.0
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 +110 -74
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +110 -74
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +110 -74
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +110 -74
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +110 -74
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +110 -74
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +4 -4
- package/dist/types/src/components/tooltip/index.d.ts +11 -11
- package/dist/types/src/components/tooltip/indexType.d.ts +6 -0
- package/dist/types/src/handler/PopsHandler.d.ts +3 -1
- package/dist/types/src/utils/PopsDOMUtils.d.ts +3 -3
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +11 -9
- package/package.json +1 -1
- package/src/Pops.ts +1 -1
- package/src/components/panel/PanelHandleContentDetails.ts +1 -1
- package/src/components/panel/index.ts +5 -5
- package/src/components/tooltip/config.ts +1 -1
- package/src/components/tooltip/index.css +6 -1
- package/src/components/tooltip/index.ts +48 -35
- package/src/components/tooltip/indexType.ts +6 -0
- package/src/handler/PopsHandler.ts +21 -16
- package/src/utils/PopsDOMUtils.ts +9 -5
- package/src/utils/PopsInstanceUtils.ts +44 -23
|
@@ -17,6 +17,8 @@ export const PopsInstanceUtils = {
|
|
|
17
17
|
/**
|
|
18
18
|
* 获取页面中最大的z-index的元素信息
|
|
19
19
|
* @param deviation 获取最大的z-index值的偏移,默认是+1
|
|
20
|
+
* @param node 进行判断的元素,默认是document
|
|
21
|
+
* @param ignoreCallBack 执行元素处理时调用的函数,返回false可忽略不想要处理的元素
|
|
20
22
|
* @example
|
|
21
23
|
* Utils.getMaxZIndexNodeInfo();
|
|
22
24
|
* > {
|
|
@@ -24,14 +26,20 @@ export const PopsInstanceUtils = {
|
|
|
24
26
|
* zIndex: 1001
|
|
25
27
|
* }
|
|
26
28
|
**/
|
|
27
|
-
getMaxZIndexNodeInfo(
|
|
29
|
+
getMaxZIndexNodeInfo(
|
|
30
|
+
deviation = 1,
|
|
31
|
+
target: Element | ShadowRoot | Document = PopsCore.document,
|
|
32
|
+
ignoreCallBack?: (
|
|
33
|
+
$ele: Element | HTMLElement | ShadowRoot
|
|
34
|
+
) => boolean | void
|
|
35
|
+
): {
|
|
28
36
|
node: Element;
|
|
29
37
|
zIndex: number;
|
|
30
38
|
} {
|
|
31
39
|
deviation = Number.isNaN(deviation) ? 1 : deviation;
|
|
32
|
-
// 最大值2147483647
|
|
33
|
-
const maxZIndex = Math.pow(2, 31) - 1;
|
|
34
|
-
// 比较值2000000000
|
|
40
|
+
// 最大值 2147483647
|
|
41
|
+
// const maxZIndex = Math.pow(2, 31) - 1;
|
|
42
|
+
// 比较值 2000000000
|
|
35
43
|
const maxZIndexCompare = 2 * Math.pow(10, 9);
|
|
36
44
|
// 当前页面最大的z-index
|
|
37
45
|
let zIndex = 0;
|
|
@@ -51,6 +59,12 @@ export const PopsInstanceUtils = {
|
|
|
51
59
|
* @param $ele
|
|
52
60
|
*/
|
|
53
61
|
function queryMaxZIndex($ele: Element) {
|
|
62
|
+
if (typeof ignoreCallBack === "function") {
|
|
63
|
+
let ignoreResult = ignoreCallBack($ele);
|
|
64
|
+
if (typeof ignoreResult === "boolean" && !ignoreResult) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
54
68
|
/** 元素的样式 */
|
|
55
69
|
const nodeStyle = PopsCore.window.getComputedStyle($ele);
|
|
56
70
|
/* 不对position为static和display为none的元素进行获取它们的z-index */
|
|
@@ -71,50 +85,49 @@ export const PopsInstanceUtils = {
|
|
|
71
85
|
}
|
|
72
86
|
}
|
|
73
87
|
}
|
|
74
|
-
|
|
88
|
+
target.querySelectorAll("*").forEach(($ele, index) => {
|
|
75
89
|
queryMaxZIndex($ele);
|
|
76
90
|
});
|
|
77
91
|
zIndex += deviation;
|
|
78
92
|
if (zIndex >= maxZIndexCompare) {
|
|
79
93
|
// 最好不要超过最大值
|
|
80
|
-
zIndex =
|
|
94
|
+
zIndex = maxZIndexCompare;
|
|
81
95
|
}
|
|
82
96
|
return {
|
|
83
97
|
node: maxZIndexNode,
|
|
84
98
|
zIndex: zIndex,
|
|
85
99
|
};
|
|
86
100
|
},
|
|
87
|
-
/**
|
|
88
|
-
* 获取页面中最大的z-index
|
|
89
|
-
* @param deviation 获取最大的z-index值的偏移,默认是+1
|
|
90
|
-
* @example
|
|
91
|
-
* Utils.getMaxZIndex();
|
|
92
|
-
* > 1001
|
|
93
|
-
**/
|
|
94
|
-
getMaxZIndex(deviation = 1): number {
|
|
95
|
-
return this.getMaxZIndexNodeInfo(deviation).zIndex;
|
|
96
|
-
},
|
|
97
101
|
/**
|
|
98
102
|
* 获取pops所有弹窗中的最大的z-index
|
|
99
103
|
* @param deviation
|
|
100
104
|
*/
|
|
101
105
|
getPopsMaxZIndex(deviation: number = 1) {
|
|
102
106
|
deviation = Number.isNaN(deviation) ? 1 : deviation;
|
|
103
|
-
// 最大值2147483647
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
// 最大值 2147483647
|
|
108
|
+
// 最大值 2147483647
|
|
109
|
+
// const maxZIndex = Math.pow(2, 31) - 1;
|
|
110
|
+
// 比较值 2000000000
|
|
111
|
+
const maxZIndexCompare = 2 * Math.pow(10, 9);
|
|
106
112
|
// 当前页面最大的z-index
|
|
107
113
|
let zIndex = 0;
|
|
108
114
|
// 当前的最大z-index的元素,调试使用
|
|
109
115
|
let maxZIndexNode = null as HTMLDivElement | null;
|
|
110
116
|
|
|
117
|
+
/**
|
|
118
|
+
* 元素是否可见
|
|
119
|
+
* @param $css
|
|
120
|
+
*/
|
|
121
|
+
function isVisibleNode($css: CSSStyleDeclaration): boolean {
|
|
122
|
+
return $css.position !== "static" && $css.display !== "none";
|
|
123
|
+
}
|
|
111
124
|
Object.keys(pops.config.layer).forEach((layerName) => {
|
|
112
125
|
let layerList = pops.config.layer[layerName as PopsLayerMode];
|
|
113
126
|
for (let index = 0; index < layerList.length; index++) {
|
|
114
127
|
const layer = layerList[index];
|
|
115
128
|
let nodeStyle = window.getComputedStyle(layer.animElement);
|
|
116
129
|
/* 不对position为static和display为none的元素进行获取它们的z-index */
|
|
117
|
-
if (nodeStyle
|
|
130
|
+
if (isVisibleNode(nodeStyle)) {
|
|
118
131
|
let nodeZIndex = parseInt(nodeStyle.zIndex);
|
|
119
132
|
if (!isNaN(nodeZIndex)) {
|
|
120
133
|
if (nodeZIndex > zIndex) {
|
|
@@ -126,14 +139,22 @@ export const PopsInstanceUtils = {
|
|
|
126
139
|
}
|
|
127
140
|
});
|
|
128
141
|
zIndex += deviation;
|
|
129
|
-
// 用于比较的值2000000000,大于该值就取该值
|
|
130
|
-
let maxZIndexCompare = 2 * Math.pow(10, 9);
|
|
131
142
|
if (zIndex >= maxZIndexCompare) {
|
|
132
143
|
// 最好不要超过最大值
|
|
133
|
-
zIndex =
|
|
144
|
+
zIndex = maxZIndexCompare;
|
|
134
145
|
}
|
|
135
146
|
return { zIndex: zIndex, animElement: maxZIndexNode };
|
|
136
147
|
},
|
|
148
|
+
/**
|
|
149
|
+
* 获取页面中最大的z-index
|
|
150
|
+
* @param deviation 获取最大的z-index值的偏移,默认是+1
|
|
151
|
+
* @example
|
|
152
|
+
* Utils.getMaxZIndex();
|
|
153
|
+
* > 1001
|
|
154
|
+
**/
|
|
155
|
+
getMaxZIndex(deviation = 1): number {
|
|
156
|
+
return this.getMaxZIndexNodeInfo(deviation).zIndex;
|
|
157
|
+
},
|
|
137
158
|
/**
|
|
138
159
|
* 获取CSS Rule
|
|
139
160
|
* @param sheet
|