@whitesev/pops 1.8.8 → 1.8.9
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 +48 -37
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +48 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +48 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +48 -37
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +48 -37
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +48 -37
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +2 -2
- 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/utils/PopsDOMUtils.d.ts +3 -3
- package/package.json +1 -1
- package/src/Pops.ts +1 -1
- package/src/components/panel/PanelHandleContentDetails.ts +1 -1
- 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/utils/PopsDOMUtils.ts +9 -5
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;
|
|
@@ -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将无效
|
|
@@ -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 要获取宽度的元素
|
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
|
});
|
|
@@ -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将无效
|
|
@@ -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
|
);
|