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
64bd6a7c
Commit
64bd6a7c
authored
Jan 09, 2014
by
Akikonata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed update bug
parent
4823c4c0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
16 deletions
+17
-16
dev.html
demo/dev.html
+8
-8
layout.js
src/module/layout.js
+9
-8
No files found.
demo/dev.html
View file @
64bd6a7c
...
...
@@ -42,13 +42,13 @@
minder
.
execCommand
(
"rendernode"
,
_root
);
//模拟生成一个初始图
//
for(var j=0;j
<
20
;
j
++
){
//
var appendSide = Math.random()>0.5?"left":"right";
//
var layerArray = _root.getData("layer"+appendSide);
//
var layer = parseInt(Math.random()*layerArray.length);
//
var layerData = layerArray[layer];
//
var root = layerData[parseInt(Math.random()*layerData.length)]
//
minder.execCommand("createchildnode",root);
//
}
for
(
var
j
=
0
;
j
<
20
;
j
++
){
var
appendSide
=
Math
.
random
()
>
0.5
?
"left"
:
"right"
;
var
layerArray
=
_root
.
getData
(
"layer"
+
appendSide
);
var
layer
=
parseInt
(
Math
.
random
()
*
layerArray
.
length
);
var
layerData
=
layerArray
[
layer
];
var
root
=
layerData
[
parseInt
(
Math
.
random
()
*
layerData
.
length
)]
minder
.
execCommand
(
"createchildnode"
,
root
);
}
</script>
</html>
\ No newline at end of file
src/module/layout.js
View file @
64bd6a7c
...
...
@@ -19,7 +19,6 @@ KityMinder.registerModule( "LayoutModule", function () {
node
.
setData
(
"branchheight"
,
defaultHeight
+
10
);
if
(
isAdd
)
{
var
add
=
(
(
siblings
.
length
===
1
&&
node
.
getParent
()
!==
root
)
?
0
:
(
defaultHeight
+
10
)
);
console
.
log
(
add
);
while
(
parent
||
(
parent
===
root
)
)
{
var
branchheight
=
parent
.
getData
(
appendSide
+
"Height"
)
||
parent
.
getData
(
"branchheight"
)
||
0
;
if
(
parent
===
root
)
{
...
...
@@ -71,8 +70,9 @@ KityMinder.registerModule( "LayoutModule", function () {
}
};
var
g
etX
=
function
(
node
)
{
var
s
etX
=
function
(
node
)
{
var
parent
=
node
.
getParent
();
if
(
!
parent
)
return
false
;
var
parentX
=
parent
.
getData
(
"x"
);
var
parentWidth
=
parent
.
getRenderContainer
().
getWidth
();
var
side
=
node
.
getData
(
"appendside"
);
...
...
@@ -158,7 +158,6 @@ KityMinder.registerModule( "LayoutModule", function () {
var
rightCount
=
parent
.
getData
(
"layerright"
);
leftCount
=
leftCount
[
1
]
?
leftCount
[
1
].
length
:
0
;
rightCount
=
rightCount
[
1
]
?
rightCount
[
1
].
length
:
0
;
console
.
log
(
leftCount
,
rightCount
);
if
(
rightCount
>
leftCount
&&
rightCount
>
1
)
{
parent
.
setData
(
"appendside"
,
"left"
);
}
else
{
...
...
@@ -225,7 +224,6 @@ KityMinder.registerModule( "LayoutModule", function () {
}
}
var
reAnal
=
updateBranchHeight
(
nodes
[
i
],
appendSide
,
root
,
false
,
parent
);
console
.
log
(
layerArray
);
if
(
reAnal
)
{
reAnalyze
(
km
,
layerArray
,
appendSide
);
}
...
...
@@ -251,18 +249,21 @@ KityMinder.registerModule( "LayoutModule", function () {
var
root
=
km
.
getRoot
();
var
rerender
=
false
;
for
(
var
key
in
feature
)
{
node
.
setData
(
"key"
,
feature
[
key
]
);
node
.
setData
(
key
,
feature
[
key
]
);
if
(
key
===
"text"
)
{
rerender
=
true
;
}
}
if
(
rerender
&&
node
!==
root
)
{
km
.
execCommand
(
"rendernode"
,
node
);
if
(
rerender
)
{
node
.
preTraverse
(
function
(
subnode
)
{
s
ubnode
.
setData
(
"x"
,
getX
(
subnode
)
);
s
etX
(
subnode
);
km
.
execCommand
(
"rendernode"
,
subnode
);
}
);
}
else
{
km
.
execCommand
(
"rendernode"
,
node
);
}
return
node
;
}
};
}
)()
);
...
...
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