Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
e766a386
Commit
e766a386
authored
Jan 07, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev
parent
102f2f3c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
4 deletions
+38
-4
dev.html
demo/dev.html
+1
-0
layout.js
src/module/layout.js
+37
-4
No files found.
demo/dev.html
View file @
e766a386
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
//标记左子树和右子树的元素
//标记左子树和右子树的元素
_root
.
setData
(
"layerleft"
,[[
_root
]]);
_root
.
setData
(
"layerleft"
,[[
_root
]]);
_root
.
setData
(
"layerright"
,[[
_root
]]);
_root
.
setData
(
"layerright"
,[[
_root
]]);
_root
.
setData
(
"indexList"
,[
0
]);
//标记根节点以及添加子树的方向
//标记根节点以及添加子树的方向
_root
.
setData
(
"appendside"
,
"right"
);
_root
.
setData
(
"appendside"
,
"right"
);
...
...
src/module/layout.js
View file @
e766a386
...
@@ -13,8 +13,10 @@ KityMinder.registerModule( "LayoutModule", function () {
...
@@ -13,8 +13,10 @@ KityMinder.registerModule( "LayoutModule", function () {
root
.
setData
(
"sidecount"
,
sidecount
+
1
);
root
.
setData
(
"sidecount"
,
sidecount
+
1
);
}
}
}
}
var
_node
=
new
MinderNode
();
var
_node
=
new
MinderNode
();
parent
.
insertChild
(
_node
,
index
);
parent
.
insertChild
(
_node
,
index
);
_node
.
setData
(
"appendside"
,
appendSide
);
_node
.
setData
(
"appendside"
,
appendSide
);
var
parentX
=
parent
.
getData
(
"x"
);
var
parentX
=
parent
.
getData
(
"x"
);
switch
(
appendSide
)
{
switch
(
appendSide
)
{
...
@@ -35,9 +37,43 @@ KityMinder.registerModule( "LayoutModule", function () {
...
@@ -35,9 +37,43 @@ KityMinder.registerModule( "LayoutModule", function () {
layerArray
[
layer
]
=
layerArray
[
layer
]
||
[];
layerArray
[
layer
]
=
layerArray
[
layer
]
||
[];
var
layerData
=
layerArray
[
layer
];
var
layerData
=
layerArray
[
layer
];
var
insertPos
=
0
;
var
insertPos
=
0
;
_node
.
setData
(
"layer"
,
layer
);
//获取层级链
var
getIndexList
=
function
(
node
)
{
var
indexList
=
[];
var
parent
=
node
;
do
{
indexList
.
push
(
parent
.
getIndex
()
);
parent
=
parent
.
getParent
();
}
while
(
parent
);
return
indexList
.
reverse
();
};
//比较两个层级链的大小
var
indexLarger
=
function
(
List1
,
List2
)
{
var
larger
=
true
;
for
(
var
i
=
0
;
i
<
List1
.
length
;
i
++
)
{
if
(
List1
[
i
]
==
List2
[
i
]
)
{
continue
;
}
if
(
List1
[
i
]
<
List2
[
i
]
)
{
larger
=
false
;
}
break
;
}
return
larger
;
};
//选定合适的位置插入节点
for
(
var
l
=
layerData
.
length
-
1
;
l
>=
0
;
l
--
)
{
if
(
!
indexLarger
(
getIndexList
(
layerData
[
l
]
),
getIndexList
(
_node
)
)
)
{
insertPos
=
l
+
1
;
break
;
}
}
console
.
log
(
layerData
);
layerData
.
splice
(
insertPos
,
0
,
_node
);
layerData
.
splice
(
insertPos
,
0
,
_node
);
_node
.
setData
(
"layer"
,
layer
);
//设置各节点Y坐标
//设置各节点Y坐标
var
rootY
=
root
.
getData
(
"y"
);
var
rootY
=
root
.
getData
(
"y"
);
...
@@ -54,9 +90,6 @@ KityMinder.registerModule( "LayoutModule", function () {
...
@@ -54,9 +90,6 @@ KityMinder.registerModule( "LayoutModule", function () {
layerData
[
j
].
setData
(
"y"
,
sY
);
layerData
[
j
].
setData
(
"y"
,
sY
);
var
part1
=
(
layerData
[
j
].
getRenderContainer
().
getHeight
()
||
defaultHeight
)
/
2
+
15
;
var
part1
=
(
layerData
[
j
].
getRenderContainer
().
getHeight
()
||
defaultHeight
)
/
2
+
15
;
var
part2
=
layerData
[
j
+
1
]
?
(
layerData
[
j
+
1
].
getRenderContainer
().
getHeight
()
||
defaultHeight
)
/
2
:
0
;
var
part2
=
layerData
[
j
+
1
]
?
(
layerData
[
j
+
1
].
getRenderContainer
().
getHeight
()
||
defaultHeight
)
/
2
:
0
;
if
(
layerData
[
j
+
1
]
)
{
console
.
log
(
layerData
[
j
+
1
].
getRenderContainer
().
getHeight
()
);
}
sY
+=
(
part1
+
part2
);
sY
+=
(
part1
+
part2
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment