Commit 424e8b4b authored by Akikonata's avatar Akikonata

added select

parent ba2e8cfd
...@@ -17,10 +17,5 @@ ...@@ -17,10 +17,5 @@
minder = KM.createMinder(kityminder); minder = KM.createMinder(kityminder);
minder.execCommand("switchlayout","default"); minder.execCommand("switchlayout","default");
minder.execCommand("appendchildnode",new MinderNode()); minder.execCommand("appendchildnode",new MinderNode());
minder.execCommand("appendchildnode",new MinderNode());
minder.execCommand("appendchildnode",new MinderNode());
minder.execCommand("appendchildnode",new MinderNode());
minder.execCommand("appendchildnode",new MinderNode());
minder.execCommand("appendchildnode",new MinderNode());
</script> </script>
</html> </html>
\ No newline at end of file
...@@ -329,17 +329,19 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -329,17 +329,19 @@ KityMinder.registerModule( "LayoutDefault", function () {
} ); } );
return effectSet; return effectSet;
}; };
var updateArrangement = function ( node, action ) {
var set1 = updateLayoutHorizon( node );
var set2 = updateLayoutVertical( node, node.getParent(), action );
//获取水平方向和垂直方向受影响的点的并集然后进行统一translate
var set = uSet( set1, set2 );
for ( var i = 0; i < set.length; i++ ) {
translateNode( set[ i ] );
}
};
var _style = { var _style = {
renderNode: function ( node ) { renderNode: function ( node ) {
drawNode( node ); drawNode( node );
var set1 = updateLayoutHorizon( node );
var set2 = updateLayoutVertical( node, node.getParent(), "append" );
//获取水平方向和垂直方向受影响的点的并集然后进行统一translate
var set = uSet( set1, set2 );
console.log( set );
for ( var i = 0; i < set.length; i++ ) {
translateNode( set[ i ] );
}
}, },
initStyle: function () { initStyle: function () {
var _root = this.getRoot(); var _root = this.getRoot();
...@@ -369,6 +371,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -369,6 +371,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
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 );
//如果是从其他style切过来的,需要重新布局 //如果是从其他style切过来的,需要重新布局
if ( children.length !== 0 ) { if ( children.length !== 0 ) {
...@@ -406,14 +409,15 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -406,14 +409,15 @@ KityMinder.registerModule( "LayoutDefault", function () {
node.setData( "align", "left" ); node.setData( "align", "left" );
} }
if ( parent.getChildren().indexOf( node ) === -1 ) parent.appendChild( node ); if ( parent.getChildren().indexOf( node ) === -1 ) parent.appendChild( node );
this.renderNode( node ); drawNode( node );
//this.select( node ); updateArrangement( node, "append" );
}, },
appendSiblingNode: function ( sibling, node ) { appendSiblingNode: function ( sibling, node ) {
var parent = sibling.getParent(); var parent = sibling.getParent();
var index = sibling.getIndex() + 1; var index = sibling.getIndex() + 1;
parent.appendChild( node, index ); parent.appendChild( node, index );
this.renderNode( node ); drawNode( node );
updateArrangement( node, "append" );
}, },
removeNode: function ( nodes ) { removeNode: function ( nodes ) {
var root = this.getRoot(); var root = this.getRoot();
......
...@@ -26,7 +26,9 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -26,7 +26,9 @@ KityMinder.registerModule( "LayoutModule", function () {
base: Command, base: Command,
execute: function ( km, node ) { execute: function ( km, node ) {
var parent = km.getSelectedNode(); var parent = km.getSelectedNode();
return km.appendChildNode( parent, node ); km.appendChildNode( parent, node );
km.select( node );
return node;
} }
}; };
} )() ); } )() );
...@@ -34,8 +36,11 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -34,8 +36,11 @@ KityMinder.registerModule( "LayoutModule", function () {
return { return {
base: Command, base: Command,
execute: function ( km, node ) { execute: function ( km, node ) {
//km.select( node );
var sibling = km.getSelectedNode(); var sibling = km.getSelectedNode();
return km.appendSiblingNode( sibling.getParent(), node ); km.appendSiblingNode( sibling, node );
km.select( 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