From 8c7ee6d2e66de7a75c5e1da12556b981f679c1e4 Mon Sep 17 00:00:00 2001 From: ssshooter Date: Thu, 29 Sep 2022 15:41:48 +0800 Subject: [PATCH] refactor: rename variables --- src/index.less | 2 +- src/linkDiv.ts | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/index.less b/src/index.less index 8f31506d..542b9771 100644 --- a/src/index.less +++ b/src/index.less @@ -1,4 +1,4 @@ -@GAP: 15px; // node horizontal gap +@GAP: 15px; // child node horizontal gap .mind-elixir { position: relative; diff --git a/src/linkDiv.ts b/src/linkDiv.ts index 597892a0..c63da53b 100644 --- a/src/linkDiv.ts +++ b/src/linkDiv.ts @@ -71,6 +71,7 @@ export default function linkDiv(primaryNode) { const alignRight = 10000 - root.offsetWidth / 2 - primaryNodeHorizontalGap const alignLeft = 10000 + root.offsetWidth / 2 + primaryNodeHorizontalGap for (let i = 0; i < primaryNodeList.length; i++) { + let x1 = 10000 let x2, y2 const el = primaryNodeList[i] const elOffsetH = el.offsetHeight @@ -81,15 +82,14 @@ export default function linkDiv(primaryNode) { y2 = base + currentOffsetL + elOffsetH / 2 // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#path_commands - let LEFT = 10000 if (this.primaryLinkStyle === 2) { if (this.direction === SIDE) { - LEFT = 10000 - root.offsetWidth / 6 + x1 = 10000 - root.offsetWidth / 6 } if (y2 < 10000) { - primaryPath += `M ${LEFT} 10000 V ${y2 + 20} C ${LEFT} ${y2} ${LEFT} ${y2} ${LEFT - 20} ${y2} H ${x2}` + primaryPath += `M ${x1} 10000 V ${y2 + 20} C ${x1} ${y2} ${x1} ${y2} ${x1 - 20} ${y2} H ${x2}` } else { - primaryPath += `M ${LEFT} 10000 V ${y2 - 20} C ${LEFT} ${y2} ${LEFT} ${y2} ${LEFT - 20} ${y2} H ${x2}` + primaryPath += `M ${x1} 10000 V ${y2 - 20} C ${x1} ${y2} ${x1} ${y2} ${x1 - 20} ${y2} H ${x2}` } } else { primaryPath += `M 10000 10000 C 10000 10000 ${10000 + 2 * primaryNodeHorizontalGap * 0.03} ${y2} ${x2} ${y2}` @@ -106,15 +106,14 @@ export default function linkDiv(primaryNode) { x2 = alignLeft + 15 // padding y2 = base + currentOffsetR + elOffsetH / 2 - let LEFT = 10000 if (this.primaryLinkStyle === 2) { if (this.direction === SIDE) { - LEFT = 10000 + root.offsetWidth / 6 + x1 = 10000 + root.offsetWidth / 6 } if (y2 < 10000) { - primaryPath += `M ${LEFT} 10000 V ${y2 + 20} C ${LEFT} ${y2} ${LEFT} ${y2} ${LEFT + 20} ${y2} H ${x2}` + primaryPath += `M ${x1} 10000 V ${y2 + 20} C ${x1} ${y2} ${x1} ${y2} ${x1 + 20} ${y2} H ${x2}` } else { - primaryPath += `M ${LEFT} 10000 V ${y2 - 20} C ${LEFT} ${y2} ${LEFT} ${y2} ${LEFT + 20} ${y2} H ${x2}` + primaryPath += `M ${x1} 10000 V ${y2 - 20} C ${x1} ${y2} ${x1} ${y2} ${x1 + 20} ${y2} H ${x2}` } } else { primaryPath += `M 10000 10000 C 10000 10000 ${10000 + 2 * primaryNodeHorizontalGap * 0.03} ${y2} ${x2} ${y2}`