mirror of
https://github.com/lana-k/sqliteviz.git
synced 2026-11-04 08:49:25 +08:00
#142 improve tooltips
This commit is contained in:
@@ -10,4 +10,5 @@
|
|||||||
border-radius: var(--border-radius-medium);
|
border-radius: var(--border-radius-medium);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-17
@@ -3,7 +3,8 @@ export default {
|
|||||||
return {
|
return {
|
||||||
tooltipStyle: {
|
tooltipStyle: {
|
||||||
visibility: 'hidden'
|
visibility: 'hidden'
|
||||||
}
|
},
|
||||||
|
showTooltipTimeout: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -13,27 +14,30 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showTooltip(e, tooltipPosition) {
|
showTooltip(e, tooltipPosition) {
|
||||||
const position = tooltipPosition
|
this.showTooltipTimeout = setTimeout(() => {
|
||||||
? tooltipPosition.split('-')
|
const position = tooltipPosition
|
||||||
: ['top', 'right']
|
? tooltipPosition.split('-')
|
||||||
const offset = 12
|
: ['top', 'right']
|
||||||
|
const offset = 12
|
||||||
|
|
||||||
if (position[0] === 'top') {
|
if (position[0] === 'top') {
|
||||||
this.tooltipStyle.top = e.clientY - offset + 'px'
|
this.tooltipStyle.top = e.clientY - offset + 'px'
|
||||||
} else {
|
} else {
|
||||||
this.tooltipStyle.top = e.clientY + offset + 'px'
|
this.tooltipStyle.top = e.clientY + offset + 'px'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position[1] === 'right') {
|
if (position[1] === 'right') {
|
||||||
this.tooltipStyle.left = e.clientX + offset + 'px'
|
this.tooltipStyle.left = e.clientX + offset + 'px'
|
||||||
} else {
|
} else {
|
||||||
this.tooltipStyle.left =
|
this.tooltipStyle.left =
|
||||||
e.clientX - offset - this.tooltipElement.offsetWidth + 'px'
|
e.clientX - offset - this.tooltipElement.offsetWidth + 'px'
|
||||||
}
|
}
|
||||||
|
|
||||||
this.tooltipStyle.visibility = 'visible'
|
this.tooltipStyle.visibility = 'visible'
|
||||||
|
}, 500)
|
||||||
},
|
},
|
||||||
hideTooltip() {
|
hideTooltip() {
|
||||||
|
this.showTooltipTimeout && clearTimeout(this.showTooltipTimeout)
|
||||||
this.tooltipStyle.visibility = 'hidden'
|
this.tooltipStyle.visibility = 'hidden'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user