@whitesev/pops 4.0.0 → 4.0.2
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 +35 -54
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +35 -54
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +35 -54
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +35 -54
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +35 -54
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +35 -54
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Pops.d.ts +83 -25
- package/dist/types/src/config/GlobalConfig.d.ts +63 -23
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +1 -1
- package/package.json +1 -1
- package/src/Pops.ts +3 -0
- package/src/config/GlobalConfig.ts +21 -14
- package/src/css/index.css +2 -0
- package/src/handler/PopsElementHandler.ts +2 -2
- package/src/handler/PopsHandler.ts +8 -9
- package/src/utils/PopsInstanceUtils.ts +10 -31
package/dist/types/src/Pops.d.ts
CHANGED
|
@@ -223,7 +223,7 @@ declare class Pops {
|
|
|
223
223
|
InstanceUtils: {
|
|
224
224
|
getPopsMaxZIndex(deviation?: number): {
|
|
225
225
|
zIndex: number;
|
|
226
|
-
animElement:
|
|
226
|
+
animElement: HTMLElement | null;
|
|
227
227
|
isOverMaxZIndex: boolean;
|
|
228
228
|
};
|
|
229
229
|
sortElementListByProperty<T, R>(getBeforeValueFun: (value: T) => R, getAfterValueFun: (value: T) => R, sortByDesc?: boolean): (after_obj: T, before_obj: T) => 1 | 0 | -1;
|
|
@@ -235,6 +235,24 @@ declare class Pops {
|
|
|
235
235
|
sub(number1: number, number2: number): string;
|
|
236
236
|
division(number1: number, number2: number): number;
|
|
237
237
|
};
|
|
238
|
+
/** 实例处理函数 */
|
|
239
|
+
PopsInstHandler: {
|
|
240
|
+
removeInstance(totalInstConfigList: import("./types/inst").PopsInstGeneralConfig[][], guid?: string, isAll?: boolean): Promise<import("./types/inst").PopsInstGeneralConfig[][]>;
|
|
241
|
+
hide(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, popsType: import("./types/main").PopsInstStoreType, instConfigList: import("./types/inst").PopsInstGeneralConfig[], guid: string, $anim: HTMLElement, $mask?: HTMLElement): Promise<void>;
|
|
242
|
+
show(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, popsType: import("./types/main").PopsInstStoreType, instConfigList: import("./types/inst").PopsInstGeneralConfig[], guid: string, $anim: HTMLElement, $mask?: HTMLElement): Promise<void>;
|
|
243
|
+
close(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, popsType: string, instConfigList: import("./types/inst").PopsInstGeneralConfig[], guid: string, $anim: HTMLElement): Promise<void>;
|
|
244
|
+
drag($move: HTMLElement, options: {
|
|
245
|
+
dragElement: HTMLElement;
|
|
246
|
+
limit: boolean;
|
|
247
|
+
emitClick?: boolean;
|
|
248
|
+
extraDistance: number;
|
|
249
|
+
container?: Window | typeof globalThis | HTMLElement;
|
|
250
|
+
startCallBack?: (moveElement: HTMLElement, left: number, top: number) => void;
|
|
251
|
+
moveCallBack?: (moveElement: HTMLElement, left: number, top: number) => void;
|
|
252
|
+
endCallBack?: (moveElement: HTMLElement, left: number, top: number) => void;
|
|
253
|
+
preventEvent?: (event: TouchEvent | PointerEvent) => boolean;
|
|
254
|
+
}): void;
|
|
255
|
+
};
|
|
238
256
|
/** pops.panel中用于处理各个类型的工具 */
|
|
239
257
|
PanelHandlerComponents: () => {
|
|
240
258
|
asideULElement: HTMLUListElement;
|
|
@@ -727,34 +745,74 @@ declare class Pops {
|
|
|
727
745
|
*/
|
|
728
746
|
GlobalConfig: {
|
|
729
747
|
config: {
|
|
730
|
-
style?: string |
|
|
731
|
-
zIndex?:
|
|
748
|
+
style?: IFunction<string> | null | undefined;
|
|
749
|
+
zIndex?: IFunction<string | number> | null | undefined;
|
|
732
750
|
} & Partial<import("./types/components").PopsGeneralConfig> & Partial<import("./types/components").PopsDragConfig>;
|
|
733
751
|
setGlobalConfig(config: {
|
|
734
|
-
style?: string |
|
|
735
|
-
zIndex?:
|
|
752
|
+
style?: IFunction<string> | null | undefined;
|
|
753
|
+
zIndex?: IFunction<string | number> | null | undefined;
|
|
736
754
|
} & Partial<import("./types/components").PopsGeneralConfig> & Partial<import("./types/components").PopsDragConfig>): void;
|
|
737
755
|
getGlobalConfig(): {
|
|
738
|
-
style?:
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
756
|
+
style?: {
|
|
757
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
758
|
+
} | Omit<(IFunction<string> & string) | null | undefined, "zIndex"> | undefined;
|
|
759
|
+
zIndex?: {
|
|
760
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
761
|
+
} | Omit<((IFunction<string | number> | null) & IFunction<number>) | undefined, "zIndex"> | undefined;
|
|
762
|
+
useShadowRoot?: {
|
|
763
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
764
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
765
|
+
class?: {
|
|
766
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
767
|
+
} | Omit<string | undefined, "zIndex"> | undefined;
|
|
768
|
+
only?: {
|
|
769
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
770
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
771
|
+
width?: {
|
|
772
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
773
|
+
} | Omit<string | undefined, "zIndex"> | undefined;
|
|
774
|
+
height?: {
|
|
775
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
776
|
+
} | Omit<string | undefined, "zIndex"> | undefined;
|
|
777
|
+
position?: {
|
|
778
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
779
|
+
} | Omit<import("./types/position").PopsPosition | undefined, "zIndex"> | undefined;
|
|
780
|
+
animation?: {
|
|
781
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
782
|
+
} | Omit<import("./types/animation").PopsAnimation | undefined, "zIndex"> | undefined;
|
|
783
|
+
mask?: {
|
|
784
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
785
|
+
} | Omit<import("./types/mask").PopsMaskConfig | undefined, "zIndex"> | undefined;
|
|
786
|
+
forbiddenScroll?: {
|
|
787
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
788
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
789
|
+
lightStyle?: {
|
|
790
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
791
|
+
} | Omit<string | null | undefined, "zIndex"> | undefined;
|
|
792
|
+
darkStyle?: {
|
|
793
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
794
|
+
} | Omit<string | null | undefined, "zIndex"> | undefined;
|
|
795
|
+
stopKeyDownEventPropagation?: {
|
|
796
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
797
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
798
|
+
beforeAppendToPageCallBack?: {
|
|
799
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
800
|
+
} | Omit<(($shadowRoot: ShadowRoot | HTMLElement, $shadowContainer: HTMLDivElement) => void) | undefined, "zIndex"> | undefined;
|
|
801
|
+
drag?: {
|
|
802
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
803
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
804
|
+
dragLimit?: {
|
|
805
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
806
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
807
|
+
dragExtraDistance?: {
|
|
808
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
809
|
+
} | Omit<number | undefined, "zIndex"> | undefined;
|
|
810
|
+
dragMoveCallBack?: {
|
|
811
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
812
|
+
} | Omit<((moveElement: HTMLElement, left: number, top: number) => void) | undefined, "zIndex"> | undefined;
|
|
813
|
+
dragEndCallBack?: {
|
|
814
|
+
zIndex: ((IFunction<string | number> | null) & IFunction<number>) | undefined;
|
|
815
|
+
} | Omit<((moveElement: HTMLElement, left: number, top: number) => void) | undefined, "zIndex"> | undefined;
|
|
758
816
|
};
|
|
759
817
|
};
|
|
760
818
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PopsGeneralConfig, PopsDragConfig } from "../types/components";
|
|
2
|
-
type
|
|
2
|
+
type NullOrFunctionReturnType<T> = null | undefined | IFunction<T>;
|
|
3
3
|
type GlobalConfigOption = {
|
|
4
|
-
style?:
|
|
5
|
-
zIndex?:
|
|
4
|
+
style?: NullOrFunctionReturnType<string>;
|
|
5
|
+
zIndex?: NullOrFunctionReturnType<number | string>;
|
|
6
6
|
} & Partial<PopsGeneralConfig> & Partial<PopsDragConfig>;
|
|
7
7
|
export declare const GlobalConfig: {
|
|
8
8
|
config: GlobalConfigOption;
|
|
@@ -14,26 +14,66 @@ export declare const GlobalConfig: {
|
|
|
14
14
|
* 获取全局配置
|
|
15
15
|
*/
|
|
16
16
|
getGlobalConfig(): {
|
|
17
|
-
style?:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
style?: {
|
|
18
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
19
|
+
} | Omit<(IFunction<string> & string) | null | undefined, "zIndex"> | undefined;
|
|
20
|
+
zIndex?: {
|
|
21
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
22
|
+
} | Omit<((IFunction<string | number> | null) & IFunction<number>) | undefined, "zIndex"> | undefined;
|
|
23
|
+
useShadowRoot?: {
|
|
24
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
25
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
26
|
+
class?: {
|
|
27
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
28
|
+
} | Omit<string | undefined, "zIndex"> | undefined;
|
|
29
|
+
only?: {
|
|
30
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
31
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
32
|
+
width?: {
|
|
33
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
34
|
+
} | Omit<string | undefined, "zIndex"> | undefined;
|
|
35
|
+
height?: {
|
|
36
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
37
|
+
} | Omit<string | undefined, "zIndex"> | undefined;
|
|
38
|
+
position?: {
|
|
39
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
40
|
+
} | Omit<import("../types/position").PopsPosition | undefined, "zIndex"> | undefined;
|
|
41
|
+
animation?: {
|
|
42
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
43
|
+
} | Omit<import("../types/animation").PopsAnimation | undefined, "zIndex"> | undefined;
|
|
44
|
+
mask?: {
|
|
45
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
46
|
+
} | Omit<import("../types/mask").PopsMaskConfig | undefined, "zIndex"> | undefined;
|
|
47
|
+
forbiddenScroll?: {
|
|
48
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
49
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
50
|
+
lightStyle?: {
|
|
51
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
52
|
+
} | Omit<string | null | undefined, "zIndex"> | undefined;
|
|
53
|
+
darkStyle?: {
|
|
54
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
55
|
+
} | Omit<string | null | undefined, "zIndex"> | undefined;
|
|
56
|
+
stopKeyDownEventPropagation?: {
|
|
57
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
58
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
59
|
+
beforeAppendToPageCallBack?: {
|
|
60
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
61
|
+
} | Omit<(($shadowRoot: ShadowRoot | HTMLElement, $shadowContainer: HTMLDivElement) => void) | undefined, "zIndex"> | undefined;
|
|
62
|
+
drag?: {
|
|
63
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
64
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
65
|
+
dragLimit?: {
|
|
66
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
67
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
68
|
+
dragExtraDistance?: {
|
|
69
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
70
|
+
} | Omit<number | undefined, "zIndex"> | undefined;
|
|
71
|
+
dragMoveCallBack?: {
|
|
72
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
73
|
+
} | Omit<((moveElement: HTMLElement, left: number, top: number) => void) | undefined, "zIndex"> | undefined;
|
|
74
|
+
dragEndCallBack?: {
|
|
75
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
76
|
+
} | Omit<((moveElement: HTMLElement, left: number, top: number) => void) | undefined, "zIndex"> | undefined;
|
|
37
77
|
};
|
|
38
78
|
};
|
|
39
79
|
export {};
|
package/package.json
CHANGED
package/src/Pops.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { PopsTooltip } from "./components/tooltip";
|
|
|
24
24
|
import type { PopsToolTipConfig } from "./components/tooltip/types/index";
|
|
25
25
|
import { GlobalConfig } from "./config/GlobalConfig";
|
|
26
26
|
import { EventEmiter } from "./event/EventEmiter";
|
|
27
|
+
import { PopsInstHandler } from "./handler/PopsInstHandler";
|
|
27
28
|
import { PopsAnimation } from "./PopsAnimation";
|
|
28
29
|
import { PopsCore } from "./PopsCore";
|
|
29
30
|
import { PopsCSS } from "./PopsCSS";
|
|
@@ -60,6 +61,8 @@ class Pops {
|
|
|
60
61
|
InstanceUtils: PopsInstanceUtils,
|
|
61
62
|
/** pops处理float类型使用的工具类 */
|
|
62
63
|
MathFloatUtils: PopsMathFloatUtils,
|
|
64
|
+
/** 实例处理函数 */
|
|
65
|
+
PopsInstHandler,
|
|
63
66
|
/** pops.panel中用于处理各个类型的工具 */
|
|
64
67
|
PanelHandlerComponents,
|
|
65
68
|
/** pops.panel中的动画 */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { PopsGeneralConfig, PopsDragConfig } from "../types/components";
|
|
2
2
|
|
|
3
|
-
type
|
|
3
|
+
type NullOrFunctionReturnType<T> = null | undefined | IFunction<T>;
|
|
4
4
|
|
|
5
5
|
type GlobalConfigOption = {
|
|
6
|
-
style?:
|
|
7
|
-
zIndex?:
|
|
6
|
+
style?: NullOrFunctionReturnType<string>;
|
|
7
|
+
zIndex?: NullOrFunctionReturnType<number | string>;
|
|
8
8
|
} & Partial<PopsGeneralConfig> &
|
|
9
9
|
Partial<PopsDragConfig>;
|
|
10
10
|
|
|
@@ -25,7 +25,11 @@ export const GlobalConfig = {
|
|
|
25
25
|
*/
|
|
26
26
|
getGlobalConfig() {
|
|
27
27
|
const result: {
|
|
28
|
-
[P in keyof GlobalConfigOption]:
|
|
28
|
+
[P in keyof GlobalConfigOption]:
|
|
29
|
+
| ResultGlobalConfigOption<Omit<GlobalConfigOption[P], "zIndex">>
|
|
30
|
+
| {
|
|
31
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
32
|
+
};
|
|
29
33
|
} = {};
|
|
30
34
|
Object.keys(GlobalConfig.config).forEach((keyName) => {
|
|
31
35
|
const configValue = Reflect.get(GlobalConfig.config, keyName);
|
|
@@ -38,17 +42,20 @@ export const GlobalConfig = {
|
|
|
38
42
|
}
|
|
39
43
|
} else if (keyName === "zIndex") {
|
|
40
44
|
// 设置zIndex属性
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
result.zIndex = () => {
|
|
46
|
+
let zIndex = configValue == null ? "" : typeof configValue === "function" ? configValue() : configValue;
|
|
47
|
+
if (typeof zIndex === "string") {
|
|
48
|
+
const newIndex = (zIndex = Number(zIndex));
|
|
49
|
+
if (!Number.isNaN(newIndex)) {
|
|
50
|
+
return newIndex;
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
if (!Number.isNaN(zIndex)) {
|
|
54
|
+
return zIndex as number;
|
|
55
|
+
}
|
|
46
56
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
result.zIndex = zIndex;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
57
|
+
return 0;
|
|
58
|
+
};
|
|
52
59
|
} else if (keyName === "mask") {
|
|
53
60
|
const mask = GlobalConfig.config.mask == null ? {} : GlobalConfig.config.mask;
|
|
54
61
|
if (typeof mask === "object" && mask != null) {
|
package/src/css/index.css
CHANGED
|
@@ -328,7 +328,7 @@ export const PopsElementHandler = {
|
|
|
328
328
|
addLightStyle($parent: HTMLElement | ShadowRoot, style?: string | null) {
|
|
329
329
|
const darkCSS = /*css*/ `
|
|
330
330
|
@media (prefers-color-scheme: light) {
|
|
331
|
-
${style}
|
|
331
|
+
${style ?? ""}
|
|
332
332
|
}
|
|
333
333
|
`;
|
|
334
334
|
const $css = this.addStyle($parent, darkCSS);
|
|
@@ -344,7 +344,7 @@ export const PopsElementHandler = {
|
|
|
344
344
|
addDarkStyle($parent: HTMLElement | ShadowRoot, style?: string | null) {
|
|
345
345
|
const darkCSS = /*css*/ `
|
|
346
346
|
@media (prefers-color-scheme: dark) {
|
|
347
|
-
${style}
|
|
347
|
+
${style ?? ""}
|
|
348
348
|
}
|
|
349
349
|
`;
|
|
350
350
|
const $css = this.addStyle($parent, darkCSS);
|
|
@@ -615,7 +615,10 @@ export const PopsHandler = {
|
|
|
615
615
|
);
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
|
|
618
|
+
if (type !== "rightClickMenu") {
|
|
619
|
+
// rightClickMenu在配置处理时就处理了一次,这里不需要重复处理
|
|
620
|
+
config = this.handleZIndex(config);
|
|
621
|
+
}
|
|
619
622
|
|
|
620
623
|
return config;
|
|
621
624
|
},
|
|
@@ -629,15 +632,11 @@ export const PopsHandler = {
|
|
|
629
632
|
const originZIndex = config.zIndex;
|
|
630
633
|
const handler = () => {
|
|
631
634
|
let deviation = 100;
|
|
632
|
-
|
|
633
|
-
// 避免叠加覆盖
|
|
634
|
-
deviation += PopsHandler.getTargerOrFunctionValue(originZIndex) ?? 0;
|
|
635
|
-
}
|
|
635
|
+
deviation += PopsHandler.getTargerOrFunctionValue(originZIndex) ?? 0;
|
|
636
636
|
let maxZIndex = deviation;
|
|
637
|
-
const
|
|
638
|
-
|
|
639
|
-
maxZIndex
|
|
640
|
-
return maxZIndex;
|
|
637
|
+
const pointZIndex = popsUtils.getMaxZIndexNodeInfoFromPoint(deviation)[0]?.zIndex ?? 0;
|
|
638
|
+
maxZIndex = Math.max(maxZIndex, pointZIndex);
|
|
639
|
+
return maxZIndex === deviation ? maxZIndex : maxZIndex + deviation;
|
|
641
640
|
};
|
|
642
641
|
config.zIndex = handler;
|
|
643
642
|
return config;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PopsInstData } from "../PopsInst";
|
|
2
2
|
import type { PopsInstStoreType } from "../types/main";
|
|
3
|
+
import { popsUtils } from "./PopsUtils";
|
|
3
4
|
|
|
4
5
|
export const PopsInstanceUtils = {
|
|
5
6
|
/**
|
|
@@ -15,43 +16,21 @@ export const PopsInstanceUtils = {
|
|
|
15
16
|
// 当前页面最大的z-index
|
|
16
17
|
let zIndex = 0;
|
|
17
18
|
// 当前的最大z-index的元素,调试使用
|
|
18
|
-
let maxZIndexNode = null as
|
|
19
|
+
let maxZIndexNode = null as HTMLElement | null;
|
|
19
20
|
|
|
20
|
-
/**
|
|
21
|
-
* 元素是否可见
|
|
22
|
-
* @param $el
|
|
23
|
-
* @param $css
|
|
24
|
-
*/
|
|
25
|
-
function isVisibleNode($el: Element, $css: CSSStyleDeclaration): boolean {
|
|
26
|
-
let flag = true;
|
|
27
|
-
if (typeof $el.checkVisibility === "function") {
|
|
28
|
-
flag = $el.checkVisibility();
|
|
29
|
-
} else {
|
|
30
|
-
flag =
|
|
31
|
-
$css.position !== "static" && $css.display !== "none" && $css.visibility !== "hidden" && $css.opacity !== "0";
|
|
32
|
-
}
|
|
33
|
-
if (flag) {
|
|
34
|
-
// css样式上可见
|
|
35
|
-
// 再判断宽高
|
|
36
|
-
const rect = $el.getBoundingClientRect();
|
|
37
|
-
// 确保该元素的中心点在屏幕内
|
|
38
|
-
flag = rect.width > 0 && rect.height > 0 && rect.x > 0 && rect.y > 0;
|
|
39
|
-
}
|
|
40
|
-
return flag;
|
|
41
|
-
}
|
|
42
21
|
Object.keys(PopsInstData).forEach((instKeyName) => {
|
|
43
22
|
const instData = PopsInstData[instKeyName as PopsInstStoreType];
|
|
44
23
|
for (let index = 0; index < instData.length; index++) {
|
|
45
24
|
const inst = instData[index];
|
|
46
|
-
const nodeStyle = window.getComputedStyle(inst.$anim);
|
|
47
25
|
// 不对position为static和display为none的元素进行获取它们的z-index
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
26
|
+
const $elList = [inst.$anim, inst.$pops, inst.$mask].filter((it) => it instanceof HTMLElement);
|
|
27
|
+
const nodeZIndexInfoList = popsUtils.getMaxZIndexNodeInfoFromPoint($elList);
|
|
28
|
+
const maxNodeZIndexInfo = nodeZIndexInfoList[0];
|
|
29
|
+
if (maxNodeZIndexInfo) {
|
|
30
|
+
const nodeZIndex = maxNodeZIndexInfo.zIndex;
|
|
31
|
+
if (nodeZIndex > zIndex) {
|
|
32
|
+
zIndex = nodeZIndex;
|
|
33
|
+
maxZIndexNode = maxNodeZIndexInfo.node! || maxNodeZIndexInfo.positionNode!;
|
|
55
34
|
}
|
|
56
35
|
}
|
|
57
36
|
}
|