Commit b9015627 authored by techird's avatar techird

添加局部 layout 更新的方法

parent e4f05e9b
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
<a href="https://github.com/fex-team/kityminder/issues/new" target="_blank">Bug</a> | <a href="https://github.com/fex-team/kityminder/issues/new" target="_blank">Bug</a> |
<a href="mailto:kity@baidu.com" target="_blank">Contact Us</a> <a href="mailto:kity@baidu.com" target="_blank">Contact Us</a>
</p> </p>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdMini":"2","bdMiniList":[],"bdPic":"","bdStyle":"1","bdSize":"32"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
</body> </body>
<script> <script>
// create km instance // create km instance
......
...@@ -128,7 +128,7 @@ kity.extendClass(MinderNode, { ...@@ -128,7 +128,7 @@ kity.extendClass(MinderNode, {
} }
} }
this.getMinder().layout(duration); this.getMinder().layout(this, duration);
return this; return this;
}, },
...@@ -140,9 +140,11 @@ kity.extendClass(MinderNode, { ...@@ -140,9 +140,11 @@ kity.extendClass(MinderNode, {
kity.extendClass(Minder, { kity.extendClass(Minder, {
layout: function(duration) { layout: function(root, duration) {
this.getRoot().traverse(function(node) { root = root || this.getRoot();
root.traverse(function(node) {
node.setLayoutTransform(null); node.setLayoutTransform(null);
}); });
...@@ -160,9 +162,9 @@ kity.extendClass(Minder, { ...@@ -160,9 +162,9 @@ kity.extendClass(Minder, {
layout.doLayout(node); layout.doLayout(node);
} }
layoutNode(this.getRoot()); layoutNode(root);
this.applyLayoutResult(this.getRoot(), duration); this.applyLayoutResult(root, duration);
return this.fire('layout'); return this.fire('layout');
}, },
......
...@@ -64,6 +64,14 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', { ...@@ -64,6 +64,14 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
return level; return level;
}, },
/**
* 获得节点的复杂度
* @return {[type]} [description]
*/
getComplex: function() {
},
/** /**
* 获得节点的类型(root|main|sub) * 获得节点的类型(root|main|sub)
*/ */
......
...@@ -52,6 +52,10 @@ kity.extendClass(Minder, { ...@@ -52,6 +52,10 @@ kity.extendClass(Minder, {
var g = KityMinder.Geometry; var g = KityMinder.Geometry;
var i, latestBox, renderer; var i, latestBox, renderer;
this.fire('beforerender', {
node: node
});
if (!node._renderers) { if (!node._renderers) {
this._createRendererForNode(node); this._createRendererForNode(node);
} }
......
...@@ -198,7 +198,6 @@ KityMinder.registerModule('Expand', function() { ...@@ -198,7 +198,6 @@ KityMinder.registerModule('Expand', function() {
if (!node.parent) return; if (!node.parent) return;
var visible = node.parent.isExpanded(); var visible = node.parent.isExpanded();
node.getRenderContainer().setVisible(visible);
expander.setState(visible && node.children.length ? node.getData(EXPAND_STATE_DATA) : 'hide'); expander.setState(visible && node.children.length ? node.getData(EXPAND_STATE_DATA) : 'hide');
...@@ -229,6 +228,11 @@ KityMinder.registerModule('Expand', function() { ...@@ -229,6 +228,11 @@ KityMinder.registerModule('Expand', function() {
}, },
'preimport': function(e) { 'preimport': function(e) {
var json = e.json; var json = e.json;
},
'beforerender': function(e) {
var node = e.node;
var visible = !node.parent || node.parent.isExpanded();
node.getRenderContainer().setVisible(visible);
} }
}, },
renderers: { renderers: {
......
...@@ -30,7 +30,7 @@ var AppendSiblingCommand = kity.createClass('AppendSiblingCommand', { ...@@ -30,7 +30,7 @@ var AppendSiblingCommand = kity.createClass('AppendSiblingCommand', {
km.select(node, true); km.select(node, true);
node.render(); node.render();
node._lastLayoutTransform = sibling._lastLayoutTransform; node._lastLayoutTransform = sibling._lastLayoutTransform;
km.layout(300); km.layout(3000);
}, },
queryState: function(km) { queryState: function(km) {
var selectedNode = km.getSelectedNode(); var selectedNode = km.getSelectedNode();
......
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