From 4077b2a3952dcc1f9d15ff01ac85e69aad77689d Mon Sep 17 00:00:00 2001 From: Cntient Date: Tue, 15 Feb 2022 10:00:17 -0500 Subject: [PATCH] Fix: only apply random offset only when adding a new node --- client/src/components/Workflow/Editor/Node.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/src/components/Workflow/Editor/Node.vue b/client/src/components/Workflow/Editor/Node.vue index 72ce02d2368..1c647689055 100644 --- a/client/src/components/Workflow/Editor/Node.vue +++ b/client/src/components/Workflow/Editor/Node.vue @@ -88,6 +88,8 @@ import { ActiveOutputs } from "./modules/outputs"; import { attachDragging } from "./modules/dragging"; Vue.use(BootstrapVue); +const OFFSET_RANGE = 100; + export default { components: { LoadingSpan, @@ -156,14 +158,14 @@ export default { const step = this.step; const el = this.$el; if (step.position) { - el.style.top = (step.position.top + this.offsetToPreventNodeOverlap(100)) + "px"; - el.style.left = (step.position.left + this.offsetToPreventNodeOverlap(100)) + "px"; + el.style.top = step.position.top + "px"; + el.style.left = step.position.left + "px"; } else { const p = document.getElementById("canvas-viewport"); const o = document.getElementById("canvas-container"); if (p && o) { - const left = -o.offsetLeft + (p.offsetWidth - el.offsetWidth) / 2 + this.offsetToPreventNodeOverlap(100); - const top = -o.offsetTop + (p.offsetHeight - el.offsetHeight) / 2 + this.offsetToPreventNodeOverlap(100); + const left = -o.offsetLeft + (p.offsetWidth - el.offsetWidth) / 2 + this.offsetToPreventNodeOverlap(OFFSET_RANGE); + const top = -o.offsetTop + (p.offsetHeight - el.offsetHeight) / 2 + this.offsetToPreventNodeOverlap(OFFSET_RANGE); el.style.top = `${top}px`; el.style.left = `${left}px`; }