@aochuang/common 1.0.130 → 1.0.131
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/common/tooltip/popper.js +50 -0
- package/common/tooltip/tooltip.vue +5 -2
- package/components/icon/demo_index.html +26 -3
- package/components/icon/iconfont.css +7 -3
- package/components/icon/iconfont.js +1 -1
- package/components/icon/iconfont.json +7 -0
- package/components/icon/iconfont.ttf +0 -0
- package/components/icon/iconfont.woff +0 -0
- package/components/icon/iconfont.woff2 +0 -0
- package/package.json +1 -1
package/common/tooltip/popper.js
CHANGED
|
@@ -4,6 +4,26 @@ import UiTooltip from '../../components/tooltip'
|
|
|
4
4
|
const TooltipConstructor = Vue.extend(UiTooltip)
|
|
5
5
|
|
|
6
6
|
let tooltip = null
|
|
7
|
+
let referenceObserver = null
|
|
8
|
+
let referenceElm = null
|
|
9
|
+
|
|
10
|
+
function isReferenceHidden ($el) {
|
|
11
|
+
if (!$el || !document.body.contains($el)) {
|
|
12
|
+
return true
|
|
13
|
+
}
|
|
14
|
+
if (!$el.getClientRects().length) {
|
|
15
|
+
return true
|
|
16
|
+
}
|
|
17
|
+
const style = window.getComputedStyle($el)
|
|
18
|
+
return style.display === 'none' || style.visibility === 'hidden'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function checkReferenceVisible () {
|
|
22
|
+
if (isReferenceHidden(referenceElm)) {
|
|
23
|
+
hideTooltip()
|
|
24
|
+
clearTooltipReferenceWatch()
|
|
25
|
+
}
|
|
26
|
+
}
|
|
7
27
|
|
|
8
28
|
export function getTooltip () {
|
|
9
29
|
if (!tooltip) {
|
|
@@ -16,3 +36,33 @@ export function getTooltip () {
|
|
|
16
36
|
}
|
|
17
37
|
return tooltip
|
|
18
38
|
}
|
|
39
|
+
|
|
40
|
+
export function watchTooltipReference ($el) {
|
|
41
|
+
clearTooltipReferenceWatch()
|
|
42
|
+
referenceElm = $el
|
|
43
|
+
if (!referenceElm || typeof MutationObserver === 'undefined') {
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
referenceObserver = new MutationObserver(checkReferenceVisible)
|
|
47
|
+
referenceObserver.observe(document.body, {
|
|
48
|
+
childList: true,
|
|
49
|
+
subtree: true,
|
|
50
|
+
attributes: true,
|
|
51
|
+
attributeFilter: ['class', 'style', 'hidden']
|
|
52
|
+
})
|
|
53
|
+
checkReferenceVisible()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function clearTooltipReferenceWatch () {
|
|
57
|
+
if (referenceObserver) {
|
|
58
|
+
referenceObserver.disconnect()
|
|
59
|
+
referenceObserver = null
|
|
60
|
+
}
|
|
61
|
+
referenceElm = null
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function hideTooltip () {
|
|
65
|
+
if (tooltip) {
|
|
66
|
+
tooltip.visible = false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getTooltip } from './popper'
|
|
2
|
+
import { clearTooltipReferenceWatch, getTooltip, watchTooltipReference } from './popper'
|
|
3
3
|
|
|
4
4
|
let _timer = null
|
|
5
5
|
|
|
@@ -29,14 +29,17 @@ export default {
|
|
|
29
29
|
...context.listeners,
|
|
30
30
|
mouseenter (e) {
|
|
31
31
|
clearTimeout(_timer)
|
|
32
|
+
const referenceElm = e.currentTarget || e.target
|
|
32
33
|
const tooltip = getTooltip()
|
|
33
34
|
tooltip.visible = true
|
|
34
35
|
tooltip.content = context.props.text
|
|
35
36
|
tooltip.html = context.props.html
|
|
36
|
-
tooltip.setReferenceElm(
|
|
37
|
+
tooltip.setReferenceElm(referenceElm)
|
|
38
|
+
watchTooltipReference(referenceElm)
|
|
37
39
|
},
|
|
38
40
|
mouseleave () {
|
|
39
41
|
clearTimeout(_timer)
|
|
42
|
+
clearTooltipReferenceWatch()
|
|
40
43
|
const tooltip = getTooltip()
|
|
41
44
|
tooltip.visible = false
|
|
42
45
|
},
|
|
@@ -54,6 +54,12 @@
|
|
|
54
54
|
<div class="content unicode" style="display: block;">
|
|
55
55
|
<ul class="icon_lists dib-box">
|
|
56
56
|
|
|
57
|
+
<li class="dib">
|
|
58
|
+
<span class="icon iconfont"></span>
|
|
59
|
+
<div class="name">bookmark-3-line</div>
|
|
60
|
+
<div class="code-name">&#xe6f9;</div>
|
|
61
|
+
</li>
|
|
62
|
+
|
|
57
63
|
<li class="dib">
|
|
58
64
|
<span class="icon iconfont"></span>
|
|
59
65
|
<div class="name">聚合列表</div>
|
|
@@ -2400,9 +2406,9 @@
|
|
|
2400
2406
|
<pre><code class="language-css"
|
|
2401
2407
|
>@font-face {
|
|
2402
2408
|
font-family: 'iconfont';
|
|
2403
|
-
src: url('iconfont.woff2?t=
|
|
2404
|
-
url('iconfont.woff?t=
|
|
2405
|
-
url('iconfont.ttf?t=
|
|
2409
|
+
src: url('iconfont.woff2?t=1785221329948') format('woff2'),
|
|
2410
|
+
url('iconfont.woff?t=1785221329948') format('woff'),
|
|
2411
|
+
url('iconfont.ttf?t=1785221329948') format('truetype');
|
|
2406
2412
|
}
|
|
2407
2413
|
</code></pre>
|
|
2408
2414
|
<h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
|
|
@@ -2428,6 +2434,15 @@
|
|
|
2428
2434
|
<div class="content font-class">
|
|
2429
2435
|
<ul class="icon_lists dib-box">
|
|
2430
2436
|
|
|
2437
|
+
<li class="dib">
|
|
2438
|
+
<span class="icon iconfont icon-bookmark-3-line"></span>
|
|
2439
|
+
<div class="name">
|
|
2440
|
+
bookmark-3-line
|
|
2441
|
+
</div>
|
|
2442
|
+
<div class="code-name">.icon-bookmark-3-line
|
|
2443
|
+
</div>
|
|
2444
|
+
</li>
|
|
2445
|
+
|
|
2431
2446
|
<li class="dib">
|
|
2432
2447
|
<span class="icon iconfont icon-aggregation-list-line"></span>
|
|
2433
2448
|
<div class="name">
|
|
@@ -5947,6 +5962,14 @@
|
|
|
5947
5962
|
<div class="content symbol">
|
|
5948
5963
|
<ul class="icon_lists dib-box">
|
|
5949
5964
|
|
|
5965
|
+
<li class="dib">
|
|
5966
|
+
<svg class="icon svg-icon" aria-hidden="true">
|
|
5967
|
+
<use xlink:href="#icon-bookmark-3-line"></use>
|
|
5968
|
+
</svg>
|
|
5969
|
+
<div class="name">bookmark-3-line</div>
|
|
5970
|
+
<div class="code-name">#icon-bookmark-3-line</div>
|
|
5971
|
+
</li>
|
|
5972
|
+
|
|
5950
5973
|
<li class="dib">
|
|
5951
5974
|
<svg class="icon svg-icon" aria-hidden="true">
|
|
5952
5975
|
<use xlink:href="#icon-aggregation-list-line"></use>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
@font-face {
|
|
2
2
|
font-family: "iconfont"; /* Project id 4387417 */
|
|
3
|
-
src: url('iconfont.woff2?t=
|
|
4
|
-
url('iconfont.woff?t=
|
|
5
|
-
url('iconfont.ttf?t=
|
|
3
|
+
src: url('iconfont.woff2?t=1785221329948') format('woff2'),
|
|
4
|
+
url('iconfont.woff?t=1785221329948') format('woff'),
|
|
5
|
+
url('iconfont.ttf?t=1785221329948') format('truetype');
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.iconfont {
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
-moz-osx-font-smoothing: grayscale;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
.icon-bookmark-3-line:before {
|
|
17
|
+
content: "\e6f9";
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
.icon-aggregation-list-line:before {
|
|
17
21
|
content: "\e6dd";
|
|
18
22
|
}
|