Skip to content

Commit d9d4cbb

Browse files
committed
feat: save direction to exported data
1 parent e381bc6 commit d9d4cbb

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

src/index.lite.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ export interface NodeObj {
7272
}
7373
export interface MindElixirData {
7474
nodeData: NodeObj,
75-
linkData?: LinkObj
75+
linkData?: LinkObj,
76+
direction?: number,
7677
}
7778
export interface MindElixirInstance {
7879
mindElixirBox: HTMLElement,
@@ -113,12 +114,12 @@ export interface MindElixirInstance {
113114
root: HTMLElement,
114115
box: HTMLElement,
115116
svg2nd: SVGElement,
116-
linkController:SVGElement,
117+
linkController: SVGElement,
117118
P2: HTMLElement,
118119
P3: HTMLElement,
119-
line1:SVGElement,
120-
line2:SVGElement,
121-
linkSvgGroup:SVGElement,
120+
line1: SVGElement,
121+
line2: SVGElement,
122+
linkSvgGroup: SVGElement,
122123
}
123124
export interface Options {
124125
el: string | Element,
@@ -280,7 +281,10 @@ MindElixir.prototype = {
280281
expandNode,
281282
refresh,
282283

283-
init: function(data:MindElixirData) {
284+
init: function(data: MindElixirData) {
285+
if (data.direction) {
286+
this.direction = data.direction
287+
}
284288
this.nodeData = data.nodeData
285289
this.linkData = data.linkData || {}
286290
// plugin

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ export interface NodeElement extends HTMLElement {
113113
}
114114
export interface MindElixirData {
115115
nodeData: NodeObj,
116-
linkData?: LinkObj
116+
linkData?: LinkObj,
117+
direction?: number
117118
}
118119
export interface MindElixirInstance {
119120
mindElixirBox: HTMLElement,
@@ -413,6 +414,9 @@ MindElixir.prototype = {
413414
},
414415
init(data:MindElixirData) {
415416
if (!data || !data.nodeData) return new Error('MindElixir: `data` is required')
417+
if (data.direction) {
418+
this.direction = data.direction
419+
}
416420
this.nodeData = data.nodeData
417421
this.linkData = data.linkData || {}
418422
// plugin

src/interact.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export const getAllDataString = function() {
115115
const data = {
116116
nodeData: getData(this),
117117
linkData: this.linkData,
118+
direction: this.direction,
118119
}
119120
return JSON.stringify(data, (k, v) => {
120121
if (k === 'parent') return undefined
@@ -135,6 +136,7 @@ export const getAllData = function(): object {
135136
const data = {
136137
nodeData: getData(this),
137138
linkData: this.linkData,
139+
direction: this.direction,
138140
}
139141
return JSON.parse(
140142
JSON.stringify(data, (k, v) => {

src/linkDiv.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ function loopChildren(children: HTMLCollection, parent: HTMLElement, first?: boo
197197
x2 = parentOL - childT.offsetWidth + GAP
198198

199199
if (childTOT + childTOH < parentOT + parentOH / 2 + 50 && childTOT + childTOH > parentOT + parentOH / 2 - 50) {
200-
// 相差+-50内直接直线
200+
// straight line
201201
path += `M ${x1} ${y1} H ${xMiddle} V ${y2} H ${x2}`
202202
} else if (childTOT + childTOH >= parentOT + parentOH / 2) {
203-
// 子底部低于父中点
203+
// child bottom lower than parent
204204
path += `M ${x1} ${y1} H ${xMiddle} V ${y2 - TURNPOINT_R} A ${TURNPOINT_R} ${TURNPOINT_R} 0 0 1 ${xMiddle - TURNPOINT_R} ${y2} H ${x2}`
205205
} else {
206-
// 子底部高于父中点
206+
// child bottom higher than parent
207207
path += `M ${x1} ${y1} H ${xMiddle} V ${y2 + TURNPOINT_R} A ${TURNPOINT_R} ${TURNPOINT_R} 0 0 0 ${xMiddle - TURNPOINT_R} ${y2} H ${x2}`
208208
}
209209
} else if (direction === 'rhs') {

src/mouse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function(mind) {
1818
// skip circle
1919
} else {
2020
mind.unselectNode()
21-
// lite version don't have hideLinkController
21+
// lite version doesn't have hideLinkController
2222
mind.hideLinkController && mind.hideLinkController()
2323
}
2424
})

0 commit comments

Comments
 (0)