Skip to content

Commit 0c3946f

Browse files
committed
feat: calculate correct colSpan/Start when columnCount is set
1 parent a2e91cb commit 0c3946f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/components/tile-manager/position.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,31 @@ class TilesState {
7272
}
7373
}
7474

75+
/**
76+
* Checks and adjusts tile spans based on the column count of the tile manager.
77+
*/
78+
public adjustTileGridPosition(): void {
79+
const columnCount = this.manager.columnCount;
80+
81+
if (columnCount > 0) {
82+
for (const tile of this.tiles) {
83+
let colStart = tile.colStart || 0;
84+
let colStartDelta = colStart > 0 ? 1 : 0;
85+
const colSpan = tile.colSpan || 0;
86+
87+
if (colStart > columnCount) {
88+
colStart = 0;
89+
colStartDelta = 0;
90+
tile.colStart = 0;
91+
}
92+
93+
if (colStart + colSpan > columnCount) {
94+
tile.colSpan = columnCount - colStart + colStartDelta;
95+
}
96+
}
97+
}
98+
}
99+
75100
public remove(tile: IgcTileComponent): void {
76101
for (const each of this.tiles) {
77102
if (each.position >= tile.position) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ export default class IgcTileManagerComponent extends LitElement {
226226
});
227227
}
228228

229+
protected override updated() {
230+
this._tilesState.adjustTileGridPosition();
231+
}
232+
229233
protected override firstUpdated() {
230234
this._tilesState.assignPositions();
231235
this._tilesState.assignTiles();

0 commit comments

Comments
 (0)