Commit fdd070dd authored by techird's avatar techird

fix layout bug

parent b9015627
...@@ -144,9 +144,10 @@ kity.extendClass(Minder, { ...@@ -144,9 +144,10 @@ kity.extendClass(Minder, {
root = root || this.getRoot(); root = root || this.getRoot();
// traverse without root
root.traverse(function(node) { root.traverse(function(node) {
node.setLayoutTransform(null); node.setLayoutTransform(null);
}); }, true);
function layoutNode(node) { function layoutNode(node) {
......
...@@ -113,11 +113,11 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', { ...@@ -113,11 +113,11 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
* 先序遍历当前节点树 * 先序遍历当前节点树
* @param {Function} fn 遍历函数 * @param {Function} fn 遍历函数
*/ */
preTraverse: function(fn) { preTraverse: function(fn, excludeThis) {
var children = this.getChildren(); var children = this.getChildren();
var value = fn(this); if (!excludeThis) fn(this);
for (var i = 0; i < children.length; i++) { for (var i = 0; i < children.length; i++) {
value = children[i].preTraverse(fn, value); children[i].preTraverse(fn);
} }
}, },
...@@ -125,17 +125,16 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', { ...@@ -125,17 +125,16 @@ var MinderNode = KityMinder.MinderNode = kity.createClass('MinderNode', {
* 后序遍历当前节点树 * 后序遍历当前节点树
* @param {Function} fn 遍历函数 * @param {Function} fn 遍历函数
*/ */
postTraverse: function(fn) { postTraverse: function(fn, excludeThis) {
var children = this.getChildren(); var children = this.getChildren();
var value;
for (var i = 0; i < children.length; i++) { for (var i = 0; i < children.length; i++) {
value = children[i].postTraverse(fn, value); children[i].postTraverse(fn);
} }
fn(this, value); if (!excludeThis) fn(this);
}, },
traverse: function(fn) { traverse: function(fn, excludeThis) {
return this.postTraverse(fn); return this.postTraverse(fn, excludeThis);
}, },
getChildren: function() { getChildren: function() {
......
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