From 8857a7dfe5449a37dd1c097ad8f5c85eb66a9b0a Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 5 Jul 2019 16:23:05 +0000 Subject: [PATCH] Simplify nodesByPos fixup --- Layout.js | 5 ----- LayoutGroup.js | 3 +++ 2 files changed, 3 insertions(+), 5 deletions(-) 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) {