( compareWith: Layout, l: LayoutItem, fullLayout: Layout, maxY: number )
| 88 | * @returns The compacted item |
| 89 | */ |
| 90 | export function compactItemVertical( |
| 91 | compareWith: Layout, |
| 92 | l: LayoutItem, |
| 93 | fullLayout: Layout, |
| 94 | maxY: number |
| 95 | ): LayoutItem { |
| 96 | // Correct negative positions first |
| 97 | (l as Mutable<LayoutItem>).x = Math.max(l.x, 0); |
| 98 | (l as Mutable<LayoutItem>).y = Math.max(l.y, 0); |
| 99 | |
| 100 | // Limit Y to the current bottom |
| 101 | (l as Mutable<LayoutItem>).y = Math.min(maxY, l.y); |
| 102 | |
| 103 | // Move up as far as possible |
| 104 | while (l.y > 0 && !getFirstCollision(compareWith, l)) { |
| 105 | (l as Mutable<LayoutItem>).y--; |
| 106 | } |
| 107 | |
| 108 | // Resolve collisions by moving down |
| 109 | let collision: LayoutItem | undefined; |
| 110 | while ((collision = getFirstCollision(compareWith, l)) !== undefined) { |
| 111 | resolveCompactionCollision(fullLayout, l, collision.y + collision.h, "y"); |
| 112 | } |
| 113 | |
| 114 | (l as Mutable<LayoutItem>).y = Math.max(l.y, 0); |
| 115 | return l; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Compact a single item horizontally (move left). |
no test coverage detected
searching dependent graphs…