Grid: rename moveColumn

This commit is contained in:
Peter Fajdiga
2024-07-08 12:00:39 +02:00
parent 3d3e8cff17
commit 4e3d924366
2 changed files with 11 additions and 11 deletions

View File

@@ -19,7 +19,7 @@ class Column {
public moveToGrid(targetGrid: Grid, prevColumn: Column|null) { public moveToGrid(targetGrid: Grid, prevColumn: Column|null) {
if (targetGrid === this.grid) { if (targetGrid === this.grid) {
this.grid.onColumnMoved(this, prevColumn); this.grid.moveColumn(this, prevColumn);
} else { } else {
this.grid.onColumnRemoved(this, false); this.grid.onColumnRemoved(this, false);
this.grid = targetGrid; this.grid = targetGrid;
@@ -34,7 +34,7 @@ class Column {
if (prevColumn === this) { if (prevColumn === this) {
return; return;
} }
this.grid.onColumnMoved(this, prevColumn); this.grid.moveColumn(this, prevColumn);
} }
public isAfter(other: Column) { public isAfter(other: Column) {

View File

@@ -24,6 +24,15 @@ class Grid {
}); });
} }
public moveColumn(column: Column, prevColumn: Column|null) {
const movedLeft = prevColumn === null ? true : column.isAfter(prevColumn);
const firstMovedColumn = movedLeft ? column : this.getNextColumn(column);
this.columns.move(column, prevColumn);
this.columnsSetX(firstMovedColumn);
this.desktop.onLayoutChanged();
this.desktop.autoAdjustScroll();
}
public moveColumnLeft(column: Column) { public moveColumnLeft(column: Column) {
this.columns.moveBack(column); this.columns.moveBack(column);
this.columnsSetX(column); this.columnsSetX(column);
@@ -180,15 +189,6 @@ class Grid {
} }
} }
public onColumnMoved(column: Column, prevColumn: Column|null) {
const movedLeft = prevColumn === null ? true : column.isAfter(prevColumn);
const firstMovedColumn = movedLeft ? column : this.getNextColumn(column);
this.columns.move(column, prevColumn);
this.columnsSetX(firstMovedColumn);
this.desktop.onLayoutChanged();
this.desktop.autoAdjustScroll();
}
public onColumnWidthChanged(column: Column) { public onColumnWidthChanged(column: Column) {
const nextColumn = this.columns.getNext(column); const nextColumn = this.columns.getNext(column);
this.columnsSetX(nextColumn); this.columnsSetX(nextColumn);