MCPcopy Create free account
hub / github.com/chartbrew/chartbrew / findLeftmostX

Function findLeftmostX

client/src/modules/autoLayout.js:27–36  ·  view source on GitHub ↗
(item, placed, bpCols)

Source from the content-addressed store, hash-verified

25}
26
27function findLeftmostX(item, placed, bpCols) {
28 let x = 0;
29 const limit = Math.max(0, bpCols - item.w);
30 for (x = 0; x <= limit; x += 1) {
31 const test = { ...item, x };
32 const hasCollision = placed.some((p) => rectanglesOverlap(test, p));
33 if (!hasCollision) return x;
34 }
35 return Math.max(0, Math.min(item.x, limit));
36}
37
38function moveUp(item, others) {
39 let moved = { ...item };

Callers 1

placeGreedyFunction · 0.85

Calls 1

rectanglesOverlapFunction · 0.70

Tested by

no test coverage detected