From beb9e38b92e40f8c46cc7761639036949f711d6c Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 27 Jun 2021 14:48:43 -0500 Subject: [PATCH] Improved tooltip performance --- src/components/system/Tooltip.vue | 37 +++++++++++++++++++++---------- src/components/tree/TreeNode.vue | 5 ++--- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/components/system/Tooltip.vue b/src/components/system/Tooltip.vue index df9d93f..c4bc48a 100644 --- a/src/components/system/Tooltip.vue +++ b/src/components/system/Tooltip.vue @@ -1,10 +1,13 @@ @@ -13,6 +16,11 @@ import { coerceComponent } from '../../util/vue'; export default { name: 'tooltip', + data() { + return { + hover: false + }; + }, props: { force: Boolean, display: String, @@ -26,12 +34,20 @@ export default { computed: { tooltipDisplay() { return coerceComponent(this.display); + }, + shown() { + return this.force || this.hover; } }, provide: { tab() { return {}; } + }, + methods: { + setHover(hover) { + this.hover = hover; + } } }; @@ -59,20 +75,17 @@ export default { transform: translateX(-50%); padding: 7px; border-radius: 3px; - opacity: 0; background-color: var(--background-tooltip); color: var(--points); + z-index: 100 !important; } -.tooltip-container:hover, -.force { +.shown { z-index: 1; } -.tooltip-container:hover > .tooltip, -.force > .tooltip { - opacity: 1; - z-index: 100 !important; +.fade-enter, .fade-leave-to { + opacity: 0; } .tooltip::after { diff --git a/src/components/tree/TreeNode.vue b/src/components/tree/TreeNode.vue index 5fb92c8..3302a2f 100644 --- a/src/components/tree/TreeNode.vue +++ b/src/components/tree/TreeNode.vue @@ -24,7 +24,6 @@ import { layers } from '../../store/layers'; import { player } from '../../store/proxies'; import { coerceComponent } from '../../util/vue'; -import { formatWhole } from '../../util/bignum'; export default { name: 'tree-node', @@ -73,10 +72,10 @@ export default { } } if (player[this.id].unlocked) { - return this.layer.tooltip || `${formatWhole(player[this.id].points)} ${this.layer.resource}`; + return this.layer.tooltip || `{{ formatWhole(player.${this.id}.points) }} {{ layers.${this.id}.resource }}`; } else { return this.layer.tooltipLocked || - `Reach ${formatWhole(this.layer.requires)} ${this.layer.baseResource} to unlock (You have ${formatWhole(this.layer.baseAmount)} ${this.layer.baseResource})`; + `Reach {{ formatWhole(layers.${this.id}.requires) }} {{ layers.${this.id}.baseResource }} to unlock (You have {{ formatWhole(layers.${this.id}.baseAmount) }} {{ layers.${this.id}.baseResource }})`; } }, components() {