From 3ee1cdb3841c07ea4fd6d0ca621dce06bd8a8dcd Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sat, 9 Jul 2022 17:07:09 -0500 Subject: [PATCH] Fix Links not always updating its outer bounds --- src/features/links/Links.vue | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/features/links/Links.vue b/src/features/links/Links.vue index bbf4740..dafab2b 100644 --- a/src/features/links/Links.vue +++ b/src/features/links/Links.vue @@ -16,7 +16,7 @@ import type { Link } from "features/links/links"; import type { FeatureNode } from "game/layers"; import { BoundsInjectionKey, NodesInjectionKey } from "game/layers"; -import { computed, inject, ref, toRef, watch } from "vue"; +import { computed, inject, onMounted, ref, toRef, watch } from "vue"; import LinkVue from "./Link.vue"; const _props = defineProps<{ links?: Link[] }>(); @@ -26,11 +26,12 @@ const resizeListener = ref(null); const nodes = inject(NodesInjectionKey, ref>({})); const outerBoundingRect = inject(BoundsInjectionKey, ref(undefined)); -const boundingRect = ref(undefined); +const boundingRect = ref(resizeListener.value?.getBoundingClientRect()); watch( - [outerBoundingRect], + outerBoundingRect, () => (boundingRect.value = resizeListener.value?.getBoundingClientRect()) ); +onMounted(() => (boundingRect.value = resizeListener.value?.getBoundingClientRect())); const validLinks = computed(() => { const n = nodes.value;