diff --git a/Layout.js b/Layout.js index 7385882..5f01474 100644 --- a/Layout.js +++ b/Layout.js @@ -97,15 +97,10 @@ class Layout { continue; } obj.savePos(); - let nodesByPos = Array.from(this.nodesByPos_); obj.moveBy(offset); this.setTension(objects); let testTension = this.getTotalTension(objects); obj.restorePos(); - this.nodesByPos_.clear(); - for (let [k, v] of nodesByPos) { - this.nodesByPos_.set(k, v); - } if (testTension < newTension) { newOffset = offset; newTension = testTension; diff --git a/LayoutGroup.js b/LayoutGroup.js index 3d20535..b5fadca 100644 --- a/LayoutGroup.js +++ b/LayoutGroup.js @@ -37,6 +37,9 @@ class LayoutGroup { for (let node of this.nodes) { node.restorePos(); } + for (let node of this.nodes) { + this.nodesByPos_.set(node.pos, node); + } } moveBy(offset) {