From 572e543ba82727e187fa8e44887e9ec39889e922 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 27 Mar 2022 19:06:58 -0500 Subject: [PATCH] Made all properties in FeatureNode non-optional --- src/components/Context.vue | 4 ++-- src/features/links/Link.vue | 26 ++++++++++++-------------- src/features/links/Links.vue | 7 +++---- src/features/particles/Particles.vue | 7 +++---- src/game/layers.tsx | 4 ++-- 5 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/components/Context.vue b/src/components/Context.vue index 0a44d4a..867ffe1 100644 --- a/src/components/Context.vue +++ b/src/components/Context.vue @@ -24,11 +24,11 @@ const observerOptions = { provide(RegisterNodeInjectionKey, (id, element) => { const observer = new MutationObserver(() => updateNode(id)); observer.observe(element, observerOptions); - nodes.value[id] = { element, observer }; + nodes.value[id] = { element, observer, rect: element.getBoundingClientRect() }; nextTick(() => updateNode(id)); }); provide(UnregisterNodeInjectionKey, id => { - nodes.value[id]?.observer?.disconnect(); + nodes.value[id]?.observer.disconnect(); nodes.value[id] = undefined; }); provide(NodesInjectionKey, nodes); diff --git a/src/features/links/Link.vue b/src/features/links/Link.vue index 9159f87..8f9e17f 100644 --- a/src/features/links/Link.vue +++ b/src/features/links/Link.vue @@ -26,13 +26,12 @@ const props = toRefs(_props); const startPosition = computed(() => { const rect = props.startNode.value.rect; const boundingRect = props.boundingRect.value; - const position = - rect && boundingRect - ? { - x: rect.x + rect.width / 2 - boundingRect.x, - y: rect.y + rect.height / 2 - boundingRect.y - } - : { x: 0, y: 0 }; + const position = boundingRect + ? { + x: rect.x + rect.width / 2 - boundingRect.x, + y: rect.y + rect.height / 2 - boundingRect.y + } + : { x: 0, y: 0 }; if (props.link.value.offsetStart) { position.x += props.link.value.offsetStart.x; position.y += props.link.value.offsetStart.y; @@ -43,13 +42,12 @@ const startPosition = computed(() => { const endPosition = computed(() => { const rect = props.endNode.value.rect; const boundingRect = props.boundingRect.value; - const position = - rect && boundingRect - ? { - x: rect.x + rect.width / 2 - boundingRect.x, - y: rect.y + rect.height / 2 - boundingRect.y - } - : { x: 0, y: 0 }; + const position = boundingRect + ? { + x: rect.x + rect.width / 2 - boundingRect.x, + y: rect.y + rect.height / 2 - boundingRect.y + } + : { x: 0, y: 0 }; if (props.link.value.offsetEnd) { position.x += props.link.value.offsetEnd.x; position.y += props.link.value.offsetEnd.y; diff --git a/src/features/links/Links.vue b/src/features/links/Links.vue index cab8aae..1f821c8 100644 --- a/src/features/links/Links.vue +++ b/src/features/links/Links.vue @@ -14,7 +14,7 @@