Commit f759d12d authored by Akikonata's avatar Akikonata

fixed updatenode bug

parent 64bd6a7c
...@@ -50,5 +50,6 @@ ...@@ -50,5 +50,6 @@
var root = layerData[parseInt(Math.random()*layerData.length)] var root = layerData[parseInt(Math.random()*layerData.length)]
minder.execCommand("createchildnode",root); minder.execCommand("createchildnode",root);
} }
minder.execCommand("updatenode",_root,{"text":"234567"});
</script> </script>
</html> </html>
\ No newline at end of file
KityMinder.registerModule( "LayoutModule", function () { KityMinder.registerModule( "LayoutModule", function () {
var defaultHeight = 35; var defaultHeight = 35;
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 () {
...@@ -48,9 +45,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -48,9 +45,7 @@ KityMinder.registerModule( "LayoutModule", function () {
return true; return true;
} }
}; };
var updateBranchWidth = function ( node, appendSide ) {
};
var reAnalyze = function ( km, layerArray, appendSide ) { var reAnalyze = function ( km, layerArray, appendSide ) {
for ( var lv = 0; lv < layerArray.length; lv++ ) { for ( var lv = 0; lv < layerArray.length; lv++ ) {
var lvData = layerArray[ lv ]; var lvData = layerArray[ lv ];
...@@ -75,6 +70,9 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -75,6 +70,9 @@ KityMinder.registerModule( "LayoutModule", function () {
if ( !parent ) return false; if ( !parent ) return false;
var parentX = parent.getData( "x" ); var parentX = parent.getData( "x" );
var parentWidth = parent.getRenderContainer().getWidth(); var parentWidth = parent.getRenderContainer().getWidth();
if ( parent.getData( "align" ) === "center" ) {
parentWidth = parentWidth / 2;
}
var side = node.getData( "appendside" ); var side = node.getData( "appendside" );
if ( side === "left" ) { if ( side === "left" ) {
node.setData( "x", parentX - parentWidth - 50 ); node.setData( "x", parentX - parentWidth - 50 );
...@@ -258,6 +256,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -258,6 +256,7 @@ KityMinder.registerModule( "LayoutModule", function () {
if ( rerender ) { if ( rerender ) {
node.preTraverse( function ( subnode ) { node.preTraverse( function ( subnode ) {
setX( subnode ); setX( subnode );
console.log( subnode );
km.execCommand( "rendernode", subnode ); km.execCommand( "rendernode", subnode );
} ); } );
} else { } else {
......
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