Skip to content

Commit

Permalink
refactor: rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
SSShooter committed Sep 29, 2022
1 parent 8d93e30 commit 8c7ee6d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/index.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@GAP: 15px; // node horizontal gap
@GAP: 15px; // child node horizontal gap

.mind-elixir {
position: relative;
Expand Down
15 changes: 7 additions & 8 deletions src/linkDiv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}`
Expand All @@ -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}`
Expand Down

0 comments on commit 8c7ee6d

Please sign in to comment.