mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 10:08:52 +08:00
41 lines
900 B
JavaScript
41 lines
900 B
JavaScript
export default {
|
|
data() {
|
|
return {
|
|
tooltipStyle: {
|
|
visibility: 'hidden'
|
|
}
|
|
}
|
|
},
|
|
computed: {
|
|
tooltipElement() {
|
|
return this.$refs.tooltip
|
|
}
|
|
},
|
|
methods: {
|
|
showTooltip(e, tooltipPosition) {
|
|
const position = tooltipPosition
|
|
? tooltipPosition.split('-')
|
|
: ['top', 'right']
|
|
const offset = 12
|
|
|
|
if (position[0] === 'top') {
|
|
this.tooltipStyle.top = e.clientY - offset + 'px'
|
|
} else {
|
|
this.tooltipStyle.top = e.clientY + offset + 'px'
|
|
}
|
|
|
|
if (position[1] === 'right') {
|
|
this.tooltipStyle.left = e.clientX + offset + 'px'
|
|
} else {
|
|
this.tooltipStyle.left =
|
|
e.clientX - offset - this.tooltipElement.offsetWidth + 'px'
|
|
}
|
|
|
|
this.tooltipStyle.visibility = 'visible'
|
|
},
|
|
hideTooltip() {
|
|
this.tooltipStyle.visibility = 'hidden'
|
|
}
|
|
}
|
|
}
|