Limit naive layout algorithm iterations count
This commit is contained in:
parent
08a561bcfd
commit
29bc4a4abf
|
@ -91,7 +91,8 @@ module.exports = class LayoutEngine {
|
||||||
node.y = offsetY + (direction * (Math.floor(columnHeight / 2) - 1) * (size + margin));
|
node.y = offsetY + (direction * (Math.floor(columnHeight / 2) - 1) * (size + margin));
|
||||||
|
|
||||||
let intersected = true;
|
let intersected = true;
|
||||||
while (intersected) {
|
let iterations = 0;
|
||||||
|
while (intersected && iterations < 10) {
|
||||||
intersected = false;
|
intersected = false;
|
||||||
for (const otherNode of nodes) {
|
for (const otherNode of nodes) {
|
||||||
if (otherNode.type === 'satellite') {
|
if (otherNode.type === 'satellite') {
|
||||||
|
@ -102,6 +103,8 @@ module.exports = class LayoutEngine {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iterations += 1;
|
||||||
|
|
||||||
if (this.nodesIntersect(node, otherNode)) {
|
if (this.nodesIntersect(node, otherNode)) {
|
||||||
node.y += direction * (size + margin);
|
node.y += direction * (size + margin);
|
||||||
intersected = true;
|
intersected = true;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user