Commit 0751ed0a authored by Akikonata's avatar Akikonata

direct

parent 44acd200
......@@ -38,7 +38,6 @@
//标记根节点以及添加子树的方向
_root.setData("appendside","right");
_root.setData("sidecount",0);
minder.select(_root);
minder.execCommand("rendernode",_root);
......
KityMinder.registerModule( "LayoutModule", function () {
var defaultHeight = 25;
var isOdd = function ( num ) {
return num % 2 !== 0;
};
//更新分支的高度信息
var updateBranchHeight = function ( node, appendSide, root, isAdd, oldParent ) {
var siblings = ( function () {
......@@ -71,15 +75,17 @@ KityMinder.registerModule( "LayoutModule", function () {
parent.insertChild( _node, index );
_node.setData( "appendside", appendSide );
if ( parent === root ) {
var sidecount = root.getData( "sidecount" );
if ( sidecount + 1 === 5 ) {
root.setData( "sidecount", 0 );
root.setData( "appendside", ( "leftright" ).replace( appendSide, "" ) );
var childCount = parent.getChildren().length;
console.log( childCount );
if ( isOdd( parseInt( childCount / 5 ) ) ) {
root.setData( "appendside", "left" );
} else {
root.setData( "sidecount", sidecount + 1 );
root.setData( "appendside", "right" );
}
}
var parentX = parent.getData( "x" );
var parentWidth = parent.getRenderContainer().getWidth();
......@@ -198,6 +204,14 @@ KityMinder.registerModule( "LayoutModule", function () {
if ( reAnal ) {
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 );
......
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