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

Function clampItemToGrid

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

Source from the content-addressed store, hash-verified

14}
15
16function clampItemToGrid(item, bpCols) {
17 const clamped = cloneDeep(item);
18 if (clamped.w > bpCols) clamped.w = bpCols;
19 if (clamped.x < 0) clamped.x = 0;
20 if (clamped.y < 0) clamped.y = 0;
21 if (clamped.x + clamped.w > bpCols) {
22 clamped.x = Math.max(0, bpCols - clamped.w);
23 }
24 return clamped;
25}
26
27function findLeftmostX(item, placed, bpCols) {
28 let x = 0;

Callers 2

normalizeAndCompactFunction · 0.85
placeGreedyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected