(items, bpCols)
| 87 | } |
| 88 | |
| 89 | function stretchTrailingGaps(items, bpCols) { |
| 90 | const cloned = cloneItems(items); |
| 91 | // Group by exact y (rows) |
| 92 | const rowsMap = {}; |
| 93 | cloned.forEach((it) => { |
| 94 | const key = `${it.y}`; |
| 95 | if (!rowsMap[key]) rowsMap[key] = []; |
| 96 | rowsMap[key].push(it); |
| 97 | }); |
| 98 | |
| 99 | Object.keys(rowsMap).forEach((key) => { |
| 100 | const row = rowsMap[key].sort((a, b) => a.x - b.x); |
| 101 | const last = row[row.length - 1]; |
| 102 | const rightEdge = last.x + last.w; |
| 103 | const gap = bpCols - rightEdge; |
| 104 | if (gap > 0) { |
| 105 | const originalW = Math.max(1, last.w); |
| 106 | const maxExtension = Math.max(1, Math.floor(originalW / 2)); |
| 107 | const apply = Math.min(gap, maxExtension); |
| 108 | last.w = originalW + apply; |
| 109 | } |
| 110 | }); |
| 111 | |
| 112 | return cloned; |
| 113 | } |
| 114 | |
| 115 | export function tidyLayout(layout, widgets, bp) { |
| 116 | const bpCols = cols[bp] || 12; |
no test coverage detected