Simplify nodesByPos fixup

This commit is contained in:
Ian Gulliver
2019-07-05 16:23:05 +00:00
parent 29babaf1e0
commit 8857a7dfe5
2 changed files with 3 additions and 5 deletions

View File

@@ -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;

View File

@@ -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) {