From 62b3bf8bc0c2be068a83be5dceea39b062fd9cce Mon Sep 17 00:00:00 2001 From: Gonzalo Bellver Date: Wed, 18 Jan 2012 20:02:15 -0300 Subject: [PATCH] Fixed node size change bug --- mindplot/src/main/javascript/layout/Node.js | 5 ++++- mindplot/src/main/javascript/layout/OriginalLayout.js | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mindplot/src/main/javascript/layout/Node.js b/mindplot/src/main/javascript/layout/Node.js index 95a61fe0..67de7202 100644 --- a/mindplot/src/main/javascript/layout/Node.js +++ b/mindplot/src/main/javascript/layout/Node.js @@ -94,10 +94,13 @@ mindplot.layout.Node = new Class({ }, hasPositionChanged: function() { - return this._isPropertyChanged('position'); }, + hasSizeChanged: function() { + return this._isPropertyChanged('size'); + }, + getPosition: function() { return this._getProperty('position'); }, diff --git a/mindplot/src/main/javascript/layout/OriginalLayout.js b/mindplot/src/main/javascript/layout/OriginalLayout.js index c437ac06..f627a5d4 100644 --- a/mindplot/src/main/javascript/layout/OriginalLayout.js +++ b/mindplot/src/main/javascript/layout/OriginalLayout.js @@ -89,6 +89,7 @@ mindplot.layout.OriginalLayout = new Class({ var children = this._treeSet.getChildren(node); var parent = this._treeSet.getParent(node); var childrenOrderMoved = children.some(function(child) { return child.hasOrderChanged(); }); + var childrenSizeChanged = children.some(function(child) { return child.hasSizeChanged(); }); // If ether any of the nodes has been changed of position or the height of the children is not // the same, children nodes must be repositioned .... @@ -98,7 +99,7 @@ mindplot.layout.OriginalLayout = new Class({ var heightChanged = node._branchHeight != newBranchHeight; node._heightChanged = heightChanged || parentHeightChanged; - if (childrenOrderMoved || heightChanged || parentHeightChanged) { + if (childrenOrderMoved || childrenSizeChanged || heightChanged || parentHeightChanged) { var sorter = node.getSorter(); var offsetById = sorter.computeOffsets(this._treeSet, node); var parentPosition = node.getPosition();