Fix major bug in layout iteration
This commit is contained in:
@@ -125,11 +125,15 @@ class Layout {
|
||||
if (obj.offsetCollides(offset)) {
|
||||
continue;
|
||||
}
|
||||
obj.savePos();
|
||||
for (let obj of objects) {
|
||||
obj.savePos();
|
||||
}
|
||||
obj.moveBy(offset);
|
||||
this.setTension(objects);
|
||||
let testTension = this.getTotalTension(objects);
|
||||
obj.restorePos();
|
||||
for (let obj of objects) {
|
||||
obj.restorePos();
|
||||
}
|
||||
if (testTension < baseTension) {
|
||||
obj.moveBy(offset);
|
||||
return true;
|
||||
|
||||
@@ -35,18 +35,11 @@ class LayoutGroup {
|
||||
}
|
||||
|
||||
savePos() {
|
||||
for (let node of this.nodes) {
|
||||
node.savePos();
|
||||
}
|
||||
this.savedVec_ = Array.from(this.vec);
|
||||
}
|
||||
|
||||
restorePos() {
|
||||
for (let node of this.nodes) {
|
||||
node.restorePos();
|
||||
}
|
||||
for (let node of this.nodes) {
|
||||
this.nodesByPos_.set(node.pos, node);
|
||||
}
|
||||
this.vec = this.savedVec_;
|
||||
}
|
||||
|
||||
moveBy(offset) {
|
||||
|
||||
@@ -132,10 +132,12 @@ class LayoutNode {
|
||||
|
||||
savePos() {
|
||||
this.savedPos_ = this.pos;
|
||||
this.savedVec_ = Array.from(this.vec);
|
||||
}
|
||||
|
||||
restorePos() {
|
||||
this.moveTo(this.savedPos_);
|
||||
this.vec = this.savedVec_;
|
||||
}
|
||||
|
||||
getStep() {
|
||||
|
||||
Reference in New Issue
Block a user