diff options
Diffstat (limited to 'ui/DisplayElement.js')
-rw-r--r-- | ui/DisplayElement.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ui/DisplayElement.js b/ui/DisplayElement.js index 952c78e..8a2aa71 100644 --- a/ui/DisplayElement.js +++ b/ui/DisplayElement.js @@ -77,7 +77,7 @@ module.exports = class DisplayElement extends EventEmitter { } } - addChild(child, afterIndex = this.children.length) { + addChild(child, afterIndex = this.children.length, {fixLayout = true} = {}) { // TODO Don't let a direct ancestor of this be added as a child. Don't // let itself be one of its childs either! @@ -88,10 +88,13 @@ module.exports = class DisplayElement extends EventEmitter { child.parent = this this.children.splice(afterIndex, 0, child) - child.fixLayout() + + if (fixLayout) { + child.fixLayout() + } } - removeChild(child) { + removeChild(child, {fixLayout = true} = {}) { // Removes the given child element from the children list of this // element. It won't be rendered in the future. If the given element // isn't a direct child of this element, nothing will happen. @@ -102,7 +105,10 @@ module.exports = class DisplayElement extends EventEmitter { child.parent = null this.children.splice(this.children.indexOf(child), 1) - this.fixLayout() + + if (fixLayout) { + this.fixLayout() + } } centerInParent() { |