Skip to content

Commit

Permalink
fix: fix frozen cell update problem in sort #1997
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Jul 3, 2024
1 parent 1738d23 commit 8b48212
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "fix: fix frozen cell update problem in sort #1997",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ export async function sortHorizontal(proxy: SceneProxy) {
});
}
});

// 更新同步范围
const syncLeftCol = Math.max(proxy.bodyLeftCol, proxy.screenLeftCol - proxy.screenColCount * 1);
const syncRightCol = Math.min(proxy.bodyRightCol, proxy.screenLeftCol + proxy.screenColCount * 2);

computeColsWidth(proxy.table, syncLeftCol, syncRightCol);

for (let col = proxy.colStart; col <= proxy.colEnd; col++) {
// 将该列的chartInstance清除掉
const columnGroup = proxy.table.scenegraph.getColGroup(col);
Expand All @@ -33,11 +40,6 @@ export async function sortHorizontal(proxy: SceneProxy) {
proxy.table.scenegraph.updateCellContent(col, row);
}
}
// 更新同步范围
const syncLeftCol = Math.max(proxy.bodyLeftCol, proxy.screenLeftCol - proxy.screenColCount * 1);
const syncRightCol = Math.min(proxy.bodyRightCol, proxy.screenLeftCol + proxy.screenColCount * 2);

computeColsWidth(proxy.table, syncLeftCol, syncRightCol);

updateColContent(syncLeftCol, syncRightCol, proxy);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ export async function sortVertical(proxy: SceneProxy) {
}
});

// 更新同步范围
let syncTopRow;
let syncBottomRow;
if (proxy.table.heightMode === 'autoHeight') {
syncTopRow = proxy.rowStart;
syncBottomRow = proxy.rowEnd;
} else {
syncTopRow = Math.max(proxy.bodyTopRow, proxy.screenTopRow - proxy.screenRowCount * 1);
syncBottomRow = Math.min(proxy.bodyBottomRow, proxy.screenTopRow + proxy.screenRowCount * 2);
}
// console.log('sort更新同步范围', syncTopRow, syncBottomRow);

const oldBodyHeight = proxy.table.getAllRowsHeight();

computeRowsHeight(proxy.table, syncTopRow, syncBottomRow);

const newBodyHeight = proxy.table.getAllRowsHeight();

if (oldBodyHeight !== newBodyHeight) {
proxy.table.scenegraph.updateContainerHeight(proxy.table.frozenRowCount, newBodyHeight - oldBodyHeight);
}

for (let col = 0; col < proxy.table.frozenColCount ?? 0; col++) {
// 将该列的chartInstance清除掉
const columnGroup = proxy.table.scenegraph.getColGroup(col);
Expand Down Expand Up @@ -46,28 +68,6 @@ export async function sortVertical(proxy: SceneProxy) {
}
}

// 更新同步范围
let syncTopRow;
let syncBottomRow;
if (proxy.table.heightMode === 'autoHeight') {
syncTopRow = proxy.rowStart;
syncBottomRow = proxy.rowEnd;
} else {
syncTopRow = Math.max(proxy.bodyTopRow, proxy.screenTopRow - proxy.screenRowCount * 1);
syncBottomRow = Math.min(proxy.bodyBottomRow, proxy.screenTopRow + proxy.screenRowCount * 2);
}
// console.log('sort更新同步范围', syncTopRow, syncBottomRow);

const oldBodyHeight = proxy.table.getAllRowsHeight();

computeRowsHeight(proxy.table, syncTopRow, syncBottomRow);

const newBodyHeight = proxy.table.getAllRowsHeight();

if (oldBodyHeight !== newBodyHeight) {
proxy.table.scenegraph.updateContainerHeight(proxy.table.frozenRowCount, newBodyHeight - oldBodyHeight);
}

updateRowContent(syncTopRow, syncBottomRow, proxy);

if (proxy.table.heightMode === 'autoHeight') {
Expand Down

0 comments on commit 8b48212

Please sign in to comment.