From ff926bff645d1cf779087f47cef21477222acd4b Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 30 Dec 2023 17:16:08 +0100 Subject: [PATCH] fix(exclude objects): fix tooltip position in object map (#1719) * fix(exclude objects): fix tooltip position in object map Signed-off-by: Stefan Dej * refactor: move style tag at the bottom Signed-off-by: Stefan Dej --------- Signed-off-by: Stefan Dej --- .../panels/Status/ExcludeObjectDialogMap.vue | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/components/panels/Status/ExcludeObjectDialogMap.vue b/src/components/panels/Status/ExcludeObjectDialogMap.vue index 5d8b1edba..2a5a18dcb 100644 --- a/src/components/panels/Status/ExcludeObjectDialogMap.vue +++ b/src/components/panels/Status/ExcludeObjectDialogMap.vue @@ -214,27 +214,28 @@ export default class StatusPanelObjectsDialogMap extends Mixins(BaseMixin) { } showObjectTooltip(text: string) { - if (this.$refs.tooltipObjectMap) { - this.$refs.tooltipObjectMap.innerHTML = text - this.$refs.tooltipObjectMap.style.display = 'block' - } + if (!this.$refs.tooltipObjectMap) return + + this.$refs.tooltipObjectMap.innerHTML = text + this.$refs.tooltipObjectMap.style.display = 'block' window.addEventListener('mousemove', this.moveTooltip) } hideObjectTooltip() { - if (this.$refs.tooltipObjectMap) { - this.$refs.tooltipObjectMap.style.display = 'none' - } + if (!this.$refs.tooltipObjectMap) return + + this.$refs.tooltipObjectMap.style.display = 'none' window.removeEventListener('mousemove', this.moveTooltip) } - moveTooltip(event: any) { - if (this.$refs.tooltipObjectMap) { - this.$refs.tooltipObjectMap.style.left = event.layerX - 20 + 'px' - this.$refs.tooltipObjectMap.style.top = event.layerY - 45 + 'px' - } + moveTooltip(event: MouseEvent) { + if (!this.$refs.tooltipObjectMap) return + + const top = event.offsetY - this.$refs.tooltipObjectMap.clientHeight - 15 + this.$refs.tooltipObjectMap.style.left = `${event.offsetX - 20}px` + this.$refs.tooltipObjectMap.style.top = `${top}px` } openExcludeObjectDialog(name: string) {