Skip to content

Commit 833a5c2

Browse files
authored
Update utils.js (jbaysolutions#677)
move item to compareWith bottom. jbaysolutions#676
1 parent 103b3c1 commit 833a5c2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/helpers/utils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ export function compact(layout: Layout, verticalCompact: Boolean): Layout {
111111
* Compact an item in the layout.
112112
*/
113113
export function compactItem(compareWith: Layout, l: LayoutItem, verticalCompact: boolean): LayoutItem {
114+
// move to bottom
115+
let maxY = 0;
116+
for (let i = 0, len = compareWith.length; i < len; i++) {
117+
if(maxY < compareWith[i].y) {
118+
maxY = compareWith[i].y;
119+
}
120+
}
121+
l.y = Math.max(l.y, maxY);
122+
114123
if (verticalCompact) {
115124
// Move the element up as far as it can go without colliding.
116125
while (l.y > 0 && !getFirstCollision(compareWith, l)) {

0 commit comments

Comments
 (0)