From 8c4662e6e583091ea030de97ed035dac070d2501 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 17 Apr 2021 23:53:05 +0900 Subject: [PATCH] Improve tooltip behaviour --- src/client/components/ui/tooltip.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/components/ui/tooltip.vue b/src/client/components/ui/tooltip.vue index b220fe5d8..de8c02ad4 100644 --- a/src/client/components/ui/tooltip.vue +++ b/src/client/components/ui/tooltip.vue @@ -39,7 +39,7 @@ export default defineComponent({ const contentHeight = this.$refs.content.offsetHeight; let left = rect.left + window.pageXOffset + (this.source.offsetWidth / 2); - let top = rect.top + window.pageYOffset + this.source.offsetHeight; + let top = rect.top + window.pageYOffset - contentHeight; left -= (this.$el.offsetWidth / 2); @@ -47,9 +47,9 @@ export default defineComponent({ left = window.innerWidth - contentWidth + window.pageXOffset - 1; } - if (top + contentHeight - window.pageYOffset > window.innerHeight) { - top = rect.top + window.pageYOffset - contentHeight; - this.$refs.content.style.transformOrigin = 'center bottom'; + if (top - window.pageYOffset < 0) { + top = rect.top + window.pageYOffset + this.source.offsetHeight; + this.$refs.content.style.transformOrigin = 'center top'; } this.$el.style.left = left + 'px'; @@ -81,6 +81,6 @@ export default defineComponent({ text-align: center; border-radius: 4px; pointer-events: none; - transform-origin: center top; + transform-origin: center bottom; }