Commit 22479859 authored by Akikonata's avatar Akikonata

store

parent 7c7ac886
...@@ -16,13 +16,7 @@ ...@@ -16,13 +16,7 @@
</body> </body>
<script> <script>
minder = KM.createMinder(kityminder); minder = KM.createMinder(kityminder);
minder.execCommand("appendchildnode",new MinderNode('dsf')); minder.execCommand("appendchildnode",new MinderNode('dsf'));
minder.execCommand("appendsiblingnode",new MinderNode('sdf')); minder.execCommand("appendsiblingnode",new MinderNode('sdf'));
minder.execCommand("appendchildnode",new MinderNode('sdf'));
minder.execCommand("appendsiblingnode",new MinderNode('df'));
var del = new MinderNode('sdfsdf');
minder.execCommand("appendsiblingnode",del);
minder.execCommand("removenode",del);
</script> </script>
</html> </html>
\ No newline at end of file
...@@ -75,7 +75,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -75,7 +75,7 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
node.root = parent.root; node.root = parent.root;
this.children.splice( index, 0, node ); this.children.splice( index, 0, node );
// this.handelInsert( node ); // this.handelInsert( node );
}, },
// //
......
...@@ -213,6 +213,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -213,6 +213,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
}; };
//绘制node //绘制node
var drawNode = function ( node ) { var drawNode = function ( node ) {
console.log( node );
var container = node.getRenderContainer(); var container = node.getRenderContainer();
var shape = node.getData( "shape" ); var shape = node.getData( "shape" );
if ( !shape ) new MinderNodeShape( node ); if ( !shape ) new MinderNodeShape( node );
...@@ -310,27 +311,32 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -310,27 +311,32 @@ KityMinder.registerModule( "LayoutDefault", function () {
return effectSet; return effectSet;
}; };
//以某个节点为seed对水平方向进行调整 //以某个节点为seed对水平方向进行调整(调整子树)
var updateLayoutHorizon = function ( node ) { var updateLayoutHorizon = function ( node ) {
var effectSet = []; var effectSet = [];
if ( !node.getParent() ) { node.preTraverse(
return [ node ]; function ( n ) {
var parent = n.getParent();
if ( !parent ) {
return false;
} }
node.preTraverse( function ( n ) { var sX = parent.getData( "x" );
var _style = n.getData( "style" ); var _style = n.getData( "style" );
var parent = node.getParent(); var marginLeft = _style.margin[ 3 ];
var _parentStyle = parent.getData( "style" ); var marginRight = _style.margin[ 1 ];
var parentX = parent.getData( "x" );
var parentAlign = parent.getData( "align" );
var parentWidth = parent.getRenderContainer().getWidth(); var parentWidth = parent.getRenderContainer().getWidth();
if ( parentAlign === "center" ) parentWidth = parentWidth / 2; if ( parent.getData( "align" ) === "center" ) {
var selfAppendSide = n.getData( "appendside" ); parentWidth = parentWidth / 2;
if ( selfAppendSide === "right" ) }
n.setData( "x", parentX + parentWidth + _style.margin[ 3 ] + _parentStyle.margin[ 1 ] ); var selfAlign = n.getData( "align" );
else if ( selfAlign === "left" ) {
n.setData( "x", parentX - parentWidth - _style.margin[ 3 ] - _parentStyle.margin[ 1 ] ); n.setData( "x", sX + parentWidth + marginLeft + marginRight );
} else {
n.setData( "x", sX - parentWidth - marginLeft - marginRight );
}
effectSet.push( n ); effectSet.push( n );
} ); }
);
return effectSet; return effectSet;
}; };
...@@ -361,21 +367,20 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -361,21 +367,20 @@ KityMinder.registerModule( "LayoutDefault", function () {
} ); } );
_root.setData( "x", minderWidth / 2 ); _root.setData( "x", minderWidth / 2 );
_root.setData( "y", minderHeight / 2 ); _root.setData( "y", minderHeight / 2 );
_root.setData( "layer", 0 );
_root.setData( "align", "center" ); _root.setData( "align", "center" );
_root.setData( "text", "I am the root" ); _root.setData( "text", "I am the root" );
_root.setData( "appendside", "right" ); _root.setData( "appendside", "right" );
var children = _root.getChildren(); var children = _root.getChildren();
console.log( children );
_root.setData( "leftList", [] ); _root.setData( "leftList", [] );
_root.setData( "rightList", [] ); _root.setData( "rightList", [] );
minder.renderNode( _root );
var _rootRenderContainer = _root.getRenderContainer(); var _rootRenderContainer = _root.getRenderContainer();
_root.setData( "leftHeight", _rootRenderContainer.getHeight() ); _root.setData( "leftHeight", _rootRenderContainer.getHeight() );
_root.setData( "rightHeight", _rootRenderContainer.getHeight() ); _root.setData( "rightHeight", _rootRenderContainer.getHeight() );
updateArrangement( _root );
minder.renderNode( _root );
//如果是从其他style切过来的,需要重新布局 //如果是从其他style切过来的,需要重新布局
var _buffer = _root.getChildren(); var _buffer = _root.getChildren();
......
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