Commit 0751ed0a authored by Akikonata's avatar Akikonata

direct

parent 44acd200
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
//标记根节点以及添加子树的方向 //标记根节点以及添加子树的方向
_root.setData("appendside","right"); _root.setData("appendside","right");
_root.setData("sidecount",0);
minder.select(_root); minder.select(_root);
minder.execCommand("rendernode",_root); minder.execCommand("rendernode",_root);
......
KityMinder.registerModule( "LayoutModule", function () { KityMinder.registerModule( "LayoutModule", function () {
var defaultHeight = 25; var defaultHeight = 25;
var isOdd = function ( num ) {
return num % 2 !== 0;
};
//更新分支的高度信息 //更新分支的高度信息
var updateBranchHeight = function ( node, appendSide, root, isAdd, oldParent ) { var updateBranchHeight = function ( node, appendSide, root, isAdd, oldParent ) {
var siblings = ( function () { var siblings = ( function () {
...@@ -71,15 +75,17 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -71,15 +75,17 @@ KityMinder.registerModule( "LayoutModule", function () {
parent.insertChild( _node, index ); parent.insertChild( _node, index );
_node.setData( "appendside", appendSide ); _node.setData( "appendside", appendSide );
if ( parent === root ) { if ( parent === root ) {
var sidecount = root.getData( "sidecount" ); var childCount = parent.getChildren().length;
if ( sidecount + 1 === 5 ) { console.log( childCount );
root.setData( "sidecount", 0 ); if ( isOdd( parseInt( childCount / 5 ) ) ) {
root.setData( "appendside", ( "leftright" ).replace( appendSide, "" ) ); root.setData( "appendside", "left" );
} else { } else {
root.setData( "sidecount", sidecount + 1 ); root.setData( "appendside", "right" );
} }
} }
var parentX = parent.getData( "x" ); var parentX = parent.getData( "x" );
var parentWidth = parent.getRenderContainer().getWidth(); var parentWidth = parent.getRenderContainer().getWidth();
...@@ -198,6 +204,14 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -198,6 +204,14 @@ KityMinder.registerModule( "LayoutModule", function () {
if ( reAnal ) { if ( reAnal ) {
reAnalyze( km, layerArray, appendSide ); reAnalyze( km, layerArray, appendSide );
} }
if ( parent === root ) {
var childCount = parent.getChildren().length;
if ( isOdd( parseInt( childCount / 5 ) ) ) {
root.setData( "appendside", "left" );
} else {
root.setData( "appendside", "right" );
}
}
} }
} }
this.setContentChanged( true ); this.setContentChanged( true );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment