Skip to content

Commit 515b5e2

Browse files
authored
fix branch order (#20)
1 parent 00a8310 commit 515b5e2

File tree

4 files changed

+282
-279
lines changed

4 files changed

+282
-279
lines changed

example/editor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function updateMindmap(text) {
4444
}
4545

4646
updateMindmap(text);
47+
viewer.fitView();
4748
editor.update({ value: text });
4849
editor.textarea.focus();
4950

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "webpack-start",
2+
"name": "mindtree",
33
"version": "1.0.0",
4-
"private": true,
5-
"description": "Project description",
4+
"private": false,
5+
"description": "Mindmap viewer for web",
66
"scripts": {
77
"watch": "webpack --watch --progress --mode development",
88
"start": "webpack-dev-server",

src/js/layouts/standard.js

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,46 @@
1-
import Layout from './layout'
2-
import Node from '../structure/node'
3-
import autoLayout from '../algorithms/auto-layout'
1+
import Layout from "./layout";
2+
import Node from "../structure/node";
3+
import autoLayout from "../algorithms/auto-layout";
44

55
class Standard extends Layout {
66
isHorizontal() {
7-
return true
7+
return true;
88
}
99

1010
doLayout() {
11-
const me = this
12-
const root = me.root
13-
const options = me.options
11+
const me = this;
12+
const root = me.root;
13+
const options = me.options;
1414
// separate into left and right trees
15-
const leftTree = new Node(root.data, options, true)
16-
const rightTree = new Node(root.data, options, true)
17-
const treeSize = root.children.length
18-
const rightTreeSize = Math.round(treeSize / 2)
15+
const leftTree = new Node(root.data, options, true);
16+
const rightTree = new Node(root.data, options, true);
17+
const treeSize = root.children.length;
18+
const rightTreeSize = Math.round(treeSize / 2);
1919
for (let i = 0; i < treeSize; i++) {
20-
const child = root.children[i]
20+
const child = root.children[i];
2121
if (i < rightTreeSize) {
22-
rightTree.children.push(child)
22+
rightTree.children.push(child);
2323
} else {
24-
leftTree.children.push(child)
24+
leftTree.children.push(child);
2525
}
2626
}
27+
28+
leftTree.children.reverse();
2729
// do layout for left and right trees
28-
autoLayout(rightTree, true)
29-
autoLayout(leftTree, true)
30-
leftTree.right2left()
30+
autoLayout(rightTree, true);
31+
autoLayout(leftTree, true);
32+
leftTree.right2left();
3133
// combine left and right trees
32-
rightTree.translate(leftTree.x - rightTree.x, leftTree.y - rightTree.y)
34+
rightTree.translate(leftTree.x - rightTree.x, leftTree.y - rightTree.y);
3335
// translate root
34-
root.x = leftTree.x
35-
root.y = rightTree.y
36-
const bb = root.getBoundingBox()
36+
root.x = leftTree.x;
37+
root.y = rightTree.y;
38+
const bb = root.getBoundingBox();
3739
if (bb.top < 0) {
38-
root.translate(0, -bb.top)
40+
root.translate(0, -bb.top);
3941
}
40-
return root
42+
return root;
4143
}
4244
}
4345

44-
export default Standard
46+
export default Standard;

0 commit comments

Comments
 (0)