@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
package/dist/types/src/Pops.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ declare class Pops {
|
|
|
86
86
|
DOMUtils: {
|
|
87
87
|
getAnimationEndNameList(): string[];
|
|
88
88
|
getTransitionEndNameList(): string[];
|
|
89
|
-
offset(element: HTMLElement): DOMRect;
|
|
89
|
+
offset(element: HTMLElement, calcScroll?: boolean): DOMRect;
|
|
90
90
|
width(element: HTMLElement | string | Window | Document | typeof globalThis, isShow?: boolean, parent?: HTMLElement | ShadowRoot): number;
|
|
91
91
|
height(element: HTMLElement | string | Window | Document | typeof globalThis, isShow?: boolean, parent?: HTMLElement | ShadowRoot): number;
|
|
92
92
|
outerWidth(element: HTMLElement | string | Window | Document, isShow?: boolean, parent?: HTMLElement | ShadowRoot): number;
|
|
@@ -146,15 +146,15 @@ declare class Pops {
|
|
|
146
146
|
};
|
|
147
147
|
/** pops创建的实例使用的工具类 */
|
|
148
148
|
InstanceUtils: {
|
|
149
|
-
getMaxZIndexNodeInfo(deviation?: number): {
|
|
149
|
+
getMaxZIndexNodeInfo(deviation?: number, target?: Element | ShadowRoot | Document, ignoreCallBack?: ($ele: Element | HTMLElement | ShadowRoot) => boolean | void): {
|
|
150
150
|
node: Element;
|
|
151
151
|
zIndex: number;
|
|
152
152
|
};
|
|
153
|
-
getMaxZIndex(deviation?: number): number;
|
|
154
153
|
getPopsMaxZIndex(deviation?: number): {
|
|
155
154
|
zIndex: number;
|
|
156
155
|
animElement: HTMLDivElement | null;
|
|
157
156
|
};
|
|
157
|
+
getMaxZIndex(deviation?: number): number;
|
|
158
158
|
getKeyFrames(sheet: CSSStyleSheet): {};
|
|
159
159
|
removeInstance(moreLayerConfigList: PopsLayerCommonConfig[][], guid: string, isAll?: boolean): PopsLayerCommonConfig[][];
|
|
160
160
|
hide(popsType: PopsLayerMode, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement, maskElement: HTMLElement): void;
|
|
@@ -289,7 +289,7 @@ declare class Pops {
|
|
|
289
289
|
* 提示框
|
|
290
290
|
* @param details 配置
|
|
291
291
|
*/
|
|
292
|
-
tooltip: <T extends PopsToolTipDetails>(details: T) => PopsTooltipResult<T>;
|
|
292
|
+
tooltip: <T extends PopsToolTipDetails = PopsToolTipDetails>(details: T) => PopsTooltipResult<T>;
|
|
293
293
|
/**
|
|
294
294
|
* 抽屉
|
|
295
295
|
* @param details 配置
|
|
@@ -130,39 +130,39 @@ export declare class ToolTip {
|
|
|
130
130
|
/**
|
|
131
131
|
* 动画结束事件
|
|
132
132
|
*/
|
|
133
|
-
|
|
133
|
+
toolTipAnimationFinishEvent(): void;
|
|
134
134
|
/**
|
|
135
|
-
*
|
|
135
|
+
* 监听tooltip的动画结束
|
|
136
136
|
*/
|
|
137
|
-
|
|
137
|
+
onToolTipAnimationFinishEvent(): void;
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
139
|
+
* 取消tooltip监听动画结束
|
|
140
140
|
*/
|
|
141
|
-
|
|
141
|
+
offToolTipAnimationFinishEvent(): void;
|
|
142
142
|
/**
|
|
143
143
|
* 鼠标|触摸进入事件
|
|
144
144
|
*/
|
|
145
|
-
|
|
145
|
+
toolTipMouseEnterEvent(): void;
|
|
146
146
|
/**
|
|
147
147
|
* 监听鼠标|触摸事件
|
|
148
148
|
*/
|
|
149
|
-
|
|
149
|
+
onToolTipMouseEnterEvent(): void;
|
|
150
150
|
/**
|
|
151
151
|
* 取消监听鼠标|触摸事件
|
|
152
152
|
*/
|
|
153
|
-
|
|
153
|
+
offToolTipMouseEnterEvent(): void;
|
|
154
154
|
/**
|
|
155
155
|
* 鼠标|触摸离开事件
|
|
156
156
|
*/
|
|
157
|
-
|
|
157
|
+
toolTipMouseLeaveEvent(): void;
|
|
158
158
|
/**
|
|
159
159
|
* 监听鼠标|触摸离开事件
|
|
160
160
|
*/
|
|
161
|
-
|
|
161
|
+
onToolTipMouseLeaveEvent(): void;
|
|
162
162
|
/**
|
|
163
163
|
* 取消监听鼠标|触摸离开事件
|
|
164
164
|
*/
|
|
165
|
-
|
|
165
|
+
offToolTipMouseLeaveEvent(): void;
|
|
166
166
|
}
|
|
167
167
|
export type PopsTooltipResult<T extends PopsToolTipDetails> = {
|
|
168
168
|
guid: string;
|
|
@@ -21,6 +21,12 @@ export interface PopsToolTipDetails {
|
|
|
21
21
|
* + github-tooltip
|
|
22
22
|
*/
|
|
23
23
|
className?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 是否使用fixed定位,默认是absolute
|
|
26
|
+
*
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
isFixed?: boolean;
|
|
24
30
|
/**
|
|
25
31
|
* 是否总是显示,默认为false
|
|
26
32
|
* + true 设置的triggerShowEventName、triggerCloseEventName将无效
|
|
@@ -25,6 +25,8 @@ export declare const PopsHandler: {
|
|
|
25
25
|
handleInit($shadowRoot?: ShadowRoot, cssText?: string | string[]): void;
|
|
26
26
|
/**
|
|
27
27
|
* 处理遮罩层
|
|
28
|
+
*
|
|
29
|
+
* + 设置遮罩层的点击事件
|
|
28
30
|
* @param details 传递的配置
|
|
29
31
|
*/
|
|
30
32
|
handleMask(details?: {
|
|
@@ -38,7 +40,7 @@ export declare const PopsHandler: {
|
|
|
38
40
|
};
|
|
39
41
|
/**
|
|
40
42
|
* 处理获取元素
|
|
41
|
-
* @param
|
|
43
|
+
* @param animElement
|
|
42
44
|
* @param type
|
|
43
45
|
*/
|
|
44
46
|
handleQueryElement(animElement: HTMLDivElement, type: PopsType): {
|
|
@@ -339,10 +339,10 @@ declare class PopsDOMUtils extends PopsDOMUtilsEvent {
|
|
|
339
339
|
getTransitionEndNameList(): string[];
|
|
340
340
|
/**
|
|
341
341
|
* 实现jQuery中的$().offset();
|
|
342
|
-
* @param
|
|
343
|
-
* @
|
|
342
|
+
* @param element
|
|
343
|
+
* @param calcScroll 计算滚动距离
|
|
344
344
|
*/
|
|
345
|
-
offset(element: HTMLElement): DOMRect;
|
|
345
|
+
offset(element: HTMLElement, calcScroll?: boolean): DOMRect;
|
|
346
346
|
/**
|
|
347
347
|
* 获取元素的宽度
|
|
348
348
|
* @param element 要获取宽度的元素
|
|
@@ -12,6 +12,8 @@ export declare const PopsInstanceUtils: {
|
|
|
12
12
|
/**
|
|
13
13
|
* 获取页面中最大的z-index的元素信息
|
|
14
14
|
* @param deviation 获取最大的z-index值的偏移,默认是+1
|
|
15
|
+
* @param node 进行判断的元素,默认是document
|
|
16
|
+
* @param ignoreCallBack 执行元素处理时调用的函数,返回false可忽略不想要处理的元素
|
|
15
17
|
* @example
|
|
16
18
|
* Utils.getMaxZIndexNodeInfo();
|
|
17
19
|
* > {
|
|
@@ -19,18 +21,10 @@ export declare const PopsInstanceUtils: {
|
|
|
19
21
|
* zIndex: 1001
|
|
20
22
|
* }
|
|
21
23
|
**/
|
|
22
|
-
getMaxZIndexNodeInfo(deviation?: number): {
|
|
24
|
+
getMaxZIndexNodeInfo(deviation?: number, target?: Element | ShadowRoot | Document, ignoreCallBack?: ($ele: Element | HTMLElement | ShadowRoot) => boolean | void): {
|
|
23
25
|
node: Element;
|
|
24
26
|
zIndex: number;
|
|
25
27
|
};
|
|
26
|
-
/**
|
|
27
|
-
* 获取页面中最大的z-index
|
|
28
|
-
* @param deviation 获取最大的z-index值的偏移,默认是+1
|
|
29
|
-
* @example
|
|
30
|
-
* Utils.getMaxZIndex();
|
|
31
|
-
* > 1001
|
|
32
|
-
**/
|
|
33
|
-
getMaxZIndex(deviation?: number): number;
|
|
34
28
|
/**
|
|
35
29
|
* 获取pops所有弹窗中的最大的z-index
|
|
36
30
|
* @param deviation
|
|
@@ -39,6 +33,14 @@ export declare const PopsInstanceUtils: {
|
|
|
39
33
|
zIndex: number;
|
|
40
34
|
animElement: HTMLDivElement | null;
|
|
41
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* 获取页面中最大的z-index
|
|
38
|
+
* @param deviation 获取最大的z-index值的偏移,默认是+1
|
|
39
|
+
* @example
|
|
40
|
+
* Utils.getMaxZIndex();
|
|
41
|
+
* > 1001
|
|
42
|
+
**/
|
|
43
|
+
getMaxZIndex(deviation?: number): number;
|
|
42
44
|
/**
|
|
43
45
|
* 获取CSS Rule
|
|
44
46
|
* @param sheet
|
package/package.json
CHANGED
package/src/Pops.ts
CHANGED
|
@@ -283,7 +283,7 @@ class Pops {
|
|
|
283
283
|
* 提示框
|
|
284
284
|
* @param details 配置
|
|
285
285
|
*/
|
|
286
|
-
tooltip = <T extends PopsToolTipDetails>(details: T) => {
|
|
286
|
+
tooltip = <T extends PopsToolTipDetails=PopsToolTipDetails>(details: T) => {
|
|
287
287
|
let popsTooltip = new PopsTooltip(details) as PopsTooltipResult<T>;
|
|
288
288
|
return popsTooltip;
|
|
289
289
|
};
|
|
@@ -980,6 +980,7 @@ export const PanelHandleContentDetails = () => {
|
|
|
980
980
|
zIndex: () => {
|
|
981
981
|
return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
|
|
982
982
|
},
|
|
983
|
+
isFixed: true,
|
|
983
984
|
className: "github-tooltip",
|
|
984
985
|
only: false,
|
|
985
986
|
eventOption: {
|
|
@@ -1000,7 +1001,6 @@ export const PanelHandleContentDetails = () => {
|
|
|
1000
1001
|
}
|
|
1001
1002
|
},
|
|
1002
1003
|
alwaysShow: false,
|
|
1003
|
-
// only: false,
|
|
1004
1004
|
position: "top",
|
|
1005
1005
|
arrowDistance: 10,
|
|
1006
1006
|
});
|
|
@@ -93,19 +93,19 @@ export class PopsPanel {
|
|
|
93
93
|
/**
|
|
94
94
|
* 已创建的元素列表
|
|
95
95
|
*/
|
|
96
|
-
let
|
|
96
|
+
let isCreatedElementList: HTMLElement[] = [$anim];
|
|
97
97
|
|
|
98
98
|
/* 遮罩层元素 */
|
|
99
99
|
if (config.mask.enable) {
|
|
100
|
-
let
|
|
100
|
+
let { maskElement } = PopsHandler.handleMask({
|
|
101
101
|
type: PopsType,
|
|
102
102
|
guid: guid,
|
|
103
103
|
config: config,
|
|
104
104
|
animElement: $anim,
|
|
105
105
|
maskHTML: maskHTML,
|
|
106
106
|
});
|
|
107
|
-
$mask =
|
|
108
|
-
|
|
107
|
+
$mask = maskElement;
|
|
108
|
+
isCreatedElementList.push($mask);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/* 处理返回的配置 */
|
|
@@ -128,7 +128,7 @@ export class PopsPanel {
|
|
|
128
128
|
);
|
|
129
129
|
|
|
130
130
|
/* 创建到页面中 */
|
|
131
|
-
popsDOMUtils.append($shadowRoot,
|
|
131
|
+
popsDOMUtils.append($shadowRoot, isCreatedElementList);
|
|
132
132
|
if (typeof config.beforeAppendToPageCallBack === "function") {
|
|
133
133
|
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
134
134
|
}
|
|
@@ -5,9 +5,9 @@ export const PopsTooltipConfig = (): Required<PopsToolTipDetails> => {
|
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
target: null,
|
|
7
7
|
content: "默认文字",
|
|
8
|
-
|
|
9
8
|
position: "top",
|
|
10
9
|
className: "",
|
|
10
|
+
isFixed: false,
|
|
11
11
|
alwaysShow: false,
|
|
12
12
|
triggerShowEventName: "mouseenter touchstart",
|
|
13
13
|
triggerCloseEventName: "mouseleave touchend",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
--tooltip-arrow--after-width: 12px;
|
|
14
14
|
--tooltip-arrow--after-height: 12px;
|
|
15
15
|
|
|
16
|
-
position: absolute;
|
|
17
16
|
padding: var(--tooltip-padding-top) var(--tooltip-padding-right)
|
|
18
17
|
var(--tooltip-padding-bottom) var(--tooltip-padding-left);
|
|
19
18
|
max-width: 400px;
|
|
@@ -24,6 +23,12 @@
|
|
|
24
23
|
color: var(--tooltip-color);
|
|
25
24
|
font-size: var(--tooltip-font-size);
|
|
26
25
|
}
|
|
26
|
+
.pops-tip[data-position="absolute"] {
|
|
27
|
+
position: absolute;
|
|
28
|
+
}
|
|
29
|
+
.pops-tip[data-position="fixed"] {
|
|
30
|
+
position: fixed;
|
|
31
|
+
}
|
|
27
32
|
/* github的样式 */
|
|
28
33
|
.pops-tip.github-tooltip {
|
|
29
34
|
--tooltip-bg-opacity: 1;
|
|
@@ -56,13 +56,20 @@ export class ToolTip {
|
|
|
56
56
|
* 创建提示元素
|
|
57
57
|
*/
|
|
58
58
|
createToolTip() {
|
|
59
|
-
let $toolTipContainer = popsDOMUtils.createElement(
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
let $toolTipContainer = popsDOMUtils.createElement(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
className: "pops-tip",
|
|
63
|
+
innerHTML: /*html*/ `
|
|
62
64
|
<div class="pops-tip-content" style="text-align: center;"></div>
|
|
63
65
|
<div class="pops-tip-arrow"></div>
|
|
64
66
|
`,
|
|
65
|
-
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"data-position": this.$data.config.isFixed ? "fixed" : "absolute",
|
|
70
|
+
"data-guid": this.$data.guid,
|
|
71
|
+
}
|
|
72
|
+
);
|
|
66
73
|
/** 内容 */
|
|
67
74
|
let $toolTipContent =
|
|
68
75
|
$toolTipContainer.querySelector<HTMLElement>(".pops-tip-content")!;
|
|
@@ -77,8 +84,6 @@ export class ToolTip {
|
|
|
77
84
|
) {
|
|
78
85
|
popsDOMUtils.addClassName($toolTipContainer, this.$data.config.className);
|
|
79
86
|
}
|
|
80
|
-
// 添加attr
|
|
81
|
-
$toolTipContainer.setAttribute("data-guid", this.$data.guid);
|
|
82
87
|
// 添加z-index
|
|
83
88
|
$toolTipContainer.style.zIndex = PopsHandler.handleZIndex(
|
|
84
89
|
this.$data.config.zIndex
|
|
@@ -140,14 +145,22 @@ export class ToolTip {
|
|
|
140
145
|
arrowDistance: number,
|
|
141
146
|
otherDistance: number
|
|
142
147
|
) {
|
|
143
|
-
let
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
let offsetInfo = popsDOMUtils.offset(
|
|
149
|
+
targetElement,
|
|
150
|
+
!this.$data.config.isFixed
|
|
151
|
+
);
|
|
152
|
+
// 目标 宽
|
|
153
|
+
let targetElement_width = offsetInfo.width;
|
|
154
|
+
// 目标 高
|
|
155
|
+
let targetElement_height = offsetInfo.height;
|
|
156
|
+
// 目标 顶部距离
|
|
157
|
+
let targetElement_top = offsetInfo.top;
|
|
146
158
|
|
|
147
|
-
// let targetElement_bottom =
|
|
148
|
-
|
|
159
|
+
// let targetElement_bottom = offsetInfo.bottom;
|
|
160
|
+
// 目标 左边距离
|
|
161
|
+
let targetElement_left = offsetInfo.left;
|
|
149
162
|
|
|
150
|
-
// let targetElement_right =
|
|
163
|
+
// let targetElement_right = offsetInfo.right;
|
|
151
164
|
|
|
152
165
|
let toolTipElement_width = popsDOMUtils.outerWidth(this.$el.$toolTip);
|
|
153
166
|
let toolTipElement_height = popsDOMUtils.outerHeight(this.$el.$toolTip);
|
|
@@ -211,21 +224,21 @@ export class ToolTip {
|
|
|
211
224
|
*/
|
|
212
225
|
onEvent() {
|
|
213
226
|
// 监听动画结束事件
|
|
214
|
-
this.
|
|
227
|
+
this.onToolTipAnimationFinishEvent();
|
|
215
228
|
this.onShowEvent();
|
|
216
229
|
this.onCloseEvent();
|
|
217
|
-
this.
|
|
218
|
-
this.
|
|
230
|
+
this.onToolTipMouseEnterEvent();
|
|
231
|
+
this.onToolTipMouseLeaveEvent();
|
|
219
232
|
}
|
|
220
233
|
/**
|
|
221
234
|
* 取消事件绑定
|
|
222
235
|
*/
|
|
223
236
|
offEvent() {
|
|
224
|
-
this.
|
|
237
|
+
this.offToolTipAnimationFinishEvent();
|
|
225
238
|
this.offShowEvent();
|
|
226
239
|
this.offCloseEvent();
|
|
227
|
-
this.
|
|
228
|
-
this.
|
|
240
|
+
this.offToolTipMouseEnterEvent();
|
|
241
|
+
this.offToolTipMouseLeaveEvent();
|
|
229
242
|
}
|
|
230
243
|
/**
|
|
231
244
|
* 添加关闭的timeId
|
|
@@ -413,7 +426,7 @@ export class ToolTip {
|
|
|
413
426
|
/**
|
|
414
427
|
* 动画结束事件
|
|
415
428
|
*/
|
|
416
|
-
|
|
429
|
+
toolTipAnimationFinishEvent() {
|
|
417
430
|
if (!this.$el.$toolTip) {
|
|
418
431
|
return;
|
|
419
432
|
}
|
|
@@ -423,29 +436,29 @@ export class ToolTip {
|
|
|
423
436
|
this.destory();
|
|
424
437
|
}
|
|
425
438
|
/**
|
|
426
|
-
*
|
|
439
|
+
* 监听tooltip的动画结束
|
|
427
440
|
*/
|
|
428
|
-
|
|
441
|
+
onToolTipAnimationFinishEvent() {
|
|
429
442
|
popsDOMUtils.on(
|
|
430
443
|
this.$el.$toolTip,
|
|
431
444
|
popsDOMUtils.getAnimationEndNameList(),
|
|
432
|
-
this.
|
|
445
|
+
this.toolTipAnimationFinishEvent.bind(this)
|
|
433
446
|
);
|
|
434
447
|
}
|
|
435
448
|
/**
|
|
436
|
-
*
|
|
449
|
+
* 取消tooltip监听动画结束
|
|
437
450
|
*/
|
|
438
|
-
|
|
451
|
+
offToolTipAnimationFinishEvent() {
|
|
439
452
|
popsDOMUtils.off(
|
|
440
453
|
this.$el.$toolTip,
|
|
441
454
|
popsDOMUtils.getAnimationEndNameList(),
|
|
442
|
-
this.
|
|
455
|
+
this.toolTipAnimationFinishEvent.bind(this)
|
|
443
456
|
);
|
|
444
457
|
}
|
|
445
458
|
/**
|
|
446
459
|
* 鼠标|触摸进入事件
|
|
447
460
|
*/
|
|
448
|
-
|
|
461
|
+
toolTipMouseEnterEvent() {
|
|
449
462
|
this.$el.$toolTip.style.animationPlayState = "paused";
|
|
450
463
|
// if (parseInt(getComputedStyle(toolTipElement)) > 0.5) {
|
|
451
464
|
// toolTipElement.style.animationPlayState = "paused";
|
|
@@ -454,52 +467,52 @@ export class ToolTip {
|
|
|
454
467
|
/**
|
|
455
468
|
* 监听鼠标|触摸事件
|
|
456
469
|
*/
|
|
457
|
-
|
|
470
|
+
onToolTipMouseEnterEvent() {
|
|
458
471
|
this.clearCloseTimeoutId("MouseEvent");
|
|
459
472
|
this.clearCloseTimeoutId("TouchEvent");
|
|
460
473
|
popsDOMUtils.on(
|
|
461
474
|
this.$el.$toolTip,
|
|
462
475
|
"mouseenter touchstart",
|
|
463
|
-
this.
|
|
476
|
+
this.toolTipMouseEnterEvent.bind(this),
|
|
464
477
|
this.$data.config.eventOption
|
|
465
478
|
);
|
|
466
479
|
}
|
|
467
480
|
/**
|
|
468
481
|
* 取消监听鼠标|触摸事件
|
|
469
482
|
*/
|
|
470
|
-
|
|
483
|
+
offToolTipMouseEnterEvent() {
|
|
471
484
|
popsDOMUtils.off(
|
|
472
485
|
this.$el.$toolTip,
|
|
473
486
|
"mouseenter touchstart",
|
|
474
|
-
this.
|
|
487
|
+
this.toolTipMouseEnterEvent.bind(this),
|
|
475
488
|
this.$data.config.eventOption
|
|
476
489
|
);
|
|
477
490
|
}
|
|
478
491
|
/**
|
|
479
492
|
* 鼠标|触摸离开事件
|
|
480
493
|
*/
|
|
481
|
-
|
|
494
|
+
toolTipMouseLeaveEvent() {
|
|
482
495
|
this.$el.$toolTip.style.animationPlayState = "running";
|
|
483
496
|
}
|
|
484
497
|
/**
|
|
485
498
|
* 监听鼠标|触摸离开事件
|
|
486
499
|
*/
|
|
487
|
-
|
|
500
|
+
onToolTipMouseLeaveEvent() {
|
|
488
501
|
popsDOMUtils.on(
|
|
489
502
|
this.$el.$toolTip,
|
|
490
503
|
"mouseleave touchend",
|
|
491
|
-
this.
|
|
504
|
+
this.toolTipMouseLeaveEvent.bind(this),
|
|
492
505
|
this.$data.config.eventOption
|
|
493
506
|
);
|
|
494
507
|
}
|
|
495
508
|
/**
|
|
496
509
|
* 取消监听鼠标|触摸离开事件
|
|
497
510
|
*/
|
|
498
|
-
|
|
511
|
+
offToolTipMouseLeaveEvent() {
|
|
499
512
|
popsDOMUtils.off(
|
|
500
513
|
this.$el.$toolTip,
|
|
501
514
|
"mouseleave touchend",
|
|
502
|
-
this.
|
|
515
|
+
this.toolTipMouseLeaveEvent.bind(this),
|
|
503
516
|
this.$data.config.eventOption
|
|
504
517
|
);
|
|
505
518
|
}
|
|
@@ -22,6 +22,12 @@ export interface PopsToolTipDetails {
|
|
|
22
22
|
* + github-tooltip
|
|
23
23
|
*/
|
|
24
24
|
className?: string;
|
|
25
|
+
/**
|
|
26
|
+
* 是否使用fixed定位,默认是absolute
|
|
27
|
+
*
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
isFixed?:boolean;
|
|
25
31
|
/**
|
|
26
32
|
* 是否总是显示,默认为false
|
|
27
33
|
* + true 设置的triggerShowEventName、triggerCloseEventName将无效
|
|
@@ -62,6 +62,8 @@ export const PopsHandler = {
|
|
|
62
62
|
},
|
|
63
63
|
/**
|
|
64
64
|
* 处理遮罩层
|
|
65
|
+
*
|
|
66
|
+
* + 设置遮罩层的点击事件
|
|
65
67
|
* @param details 传递的配置
|
|
66
68
|
*/
|
|
67
69
|
handleMask(
|
|
@@ -130,27 +132,32 @@ export const PopsHandler = {
|
|
|
130
132
|
}
|
|
131
133
|
return false;
|
|
132
134
|
}
|
|
133
|
-
|
|
134
|
-
return Boolean(
|
|
135
|
-
element?.localName?.toLowerCase() === "div" &&
|
|
136
|
-
element.className &&
|
|
137
|
-
element.className === "pops-anim" &&
|
|
138
|
-
element.hasAttribute("anim")
|
|
139
|
-
);
|
|
140
|
-
}
|
|
135
|
+
// 判断是否启用了遮罩层点击动作
|
|
141
136
|
if (
|
|
142
137
|
details.config.mask.clickEvent!.toClose ||
|
|
143
138
|
details.config.mask.clickEvent!.toHide
|
|
144
139
|
) {
|
|
140
|
+
/**
|
|
141
|
+
* 判断点击的元素是否是动画层的元素
|
|
142
|
+
* @param element
|
|
143
|
+
* @returns
|
|
144
|
+
*/
|
|
145
|
+
function isAnimElement(element: HTMLElement) {
|
|
146
|
+
return Boolean(
|
|
147
|
+
element?.localName?.toLowerCase() === "div" &&
|
|
148
|
+
element.className &&
|
|
149
|
+
element.className === "pops-anim" &&
|
|
150
|
+
element.hasAttribute("anim")
|
|
151
|
+
);
|
|
152
|
+
}
|
|
145
153
|
/* 判断按下的元素是否是pops-anim */
|
|
146
154
|
popsDOMUtils.on(
|
|
147
155
|
details.animElement,
|
|
148
156
|
["touchstart", "mousedown"],
|
|
149
157
|
void 0,
|
|
150
158
|
(event) => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
);
|
|
159
|
+
let $click = event.composedPath()[0] as HTMLElement;
|
|
160
|
+
isMaskClick = isAnimElement($click);
|
|
154
161
|
}
|
|
155
162
|
);
|
|
156
163
|
/* 如果有动画层,在动画层上监听点击事件 */
|
|
@@ -159,10 +166,8 @@ export const PopsHandler = {
|
|
|
159
166
|
"click",
|
|
160
167
|
void 0,
|
|
161
168
|
(event) => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
isMaskClick
|
|
165
|
-
) {
|
|
169
|
+
let $click = event.composedPath()[0] as HTMLElement;
|
|
170
|
+
if (isAnimElement($click) && isMaskClick) {
|
|
166
171
|
return clickEvent(event);
|
|
167
172
|
}
|
|
168
173
|
}
|
|
@@ -183,7 +188,7 @@ export const PopsHandler = {
|
|
|
183
188
|
},
|
|
184
189
|
/**
|
|
185
190
|
* 处理获取元素
|
|
186
|
-
* @param
|
|
191
|
+
* @param animElement
|
|
187
192
|
* @param type
|
|
188
193
|
*/
|
|
189
194
|
handleQueryElement(animElement: HTMLDivElement, type: PopsType) {
|
|
@@ -1107,15 +1107,19 @@ class PopsDOMUtils extends PopsDOMUtilsEvent {
|
|
|
1107
1107
|
}
|
|
1108
1108
|
/**
|
|
1109
1109
|
* 实现jQuery中的$().offset();
|
|
1110
|
-
* @param
|
|
1111
|
-
* @
|
|
1110
|
+
* @param element
|
|
1111
|
+
* @param calcScroll 计算滚动距离
|
|
1112
1112
|
*/
|
|
1113
|
-
offset(element: HTMLElement) {
|
|
1113
|
+
offset(element: HTMLElement, calcScroll: boolean = true) {
|
|
1114
1114
|
let rect = element.getBoundingClientRect();
|
|
1115
1115
|
let win = element.ownerDocument.defaultView;
|
|
1116
1116
|
let resultRect = new DOMRect(
|
|
1117
|
-
|
|
1118
|
-
|
|
1117
|
+
calcScroll
|
|
1118
|
+
? parseFloat((rect.left + (win?.pageXOffset || 0)).toString())
|
|
1119
|
+
: rect.left,
|
|
1120
|
+
calcScroll
|
|
1121
|
+
? parseFloat((rect.top + (win?.pageYOffset || 0)).toString())
|
|
1122
|
+
: rect.top,
|
|
1119
1123
|
rect.width,
|
|
1120
1124
|
rect.height
|
|
1121
1125
|
);
|