(item, placed, bpCols)
| 25 | } |
| 26 | |
| 27 | function 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 | |
| 38 | function moveUp(item, others) { |
| 39 | let moved = { ...item }; |
no test coverage detected