Commit 64bd6a7c authored by Akikonata's avatar Akikonata

fixed update bug

parent 4823c4c0
......@@ -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
......@@ -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 getX = function ( node ) {
var setX = 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 ) {
subnode.setData( "x", getX( subnode ) );
setX( subnode );
km.execCommand( "rendernode", subnode );
} );
} else {
km.execCommand( "rendernode", node );
}
return node;
}
};
} )() );
......
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