Skip to content

Commit 4e01ed5

Browse files
committed
fix: horizontal resize to max column count
1 parent db06e9a commit 4e01ed5

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

src/components/tile-manager/resize-state.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,14 @@ class TileResizeState {
273273
tilePosition: this.position.row,
274274
tileGridDimension: this.rows,
275275
gap: this._gap,
276-
allowOverflow: true,
276+
isRow,
277277
}
278278
: {
279279
targetSize: rect.width,
280280
tilePosition: this.position.column,
281281
tileGridDimension: this.columns,
282282
gap: this._gap,
283-
allowOverflow: false,
283+
isRow,
284284
};
285285
}
286286
}

src/components/tile-manager/resize-util.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ export class ResizeUtil {
8686
}
8787

8888
public calculateResizedSpan(props: ResizeSpanProps): number {
89-
const { targetSize, tilePosition, tileGridDimension, gap, allowOverflow } =
90-
props;
89+
const { targetSize, tilePosition, tileGridDimension, gap, isRow } = props;
9190
const { entries, minSize } = tileGridDimension;
9291

9392
let accumulatedSize = 0;
@@ -105,12 +104,9 @@ export class ResizeUtil {
105104
if (targetSize > availableSize) {
106105
const remainingSize = targetSize - availableSize;
107106

108-
if (allowOverflow) {
109-
const additionalSpan = Math.ceil(remainingSize / (minSize + gap));
110-
return sizesAfterStart.length + additionalSpan;
111-
}
112-
113-
return sizesAfterStart.length;
107+
const additionalSpan = Math.ceil(remainingSize / (minSize + gap));
108+
newSpan = sizesAfterStart.length + additionalSpan;
109+
return isRow ? newSpan : Math.min(entries.length, newSpan);
114110
}
115111

116112
for (let i = tilePosition.start - 1; i < entries.length; i++) {

src/components/tile-manager/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ export type ResizeSpanProps = {
2929
tilePosition: TilePosition;
3030
tileGridDimension: TileGridDimension;
3131
gap: number;
32-
allowOverflow: boolean;
32+
isRow: boolean;
3333
};

0 commit comments

Comments
 (0)