Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "fix(scenegraph): reset proxy row status when start exceeds end",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
40 changes: 40 additions & 0 deletions packages/vtable/src/scenegraph/layout/update-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export function updateRow(

scene.table._clearRowRangeHeightsMap();

// verify proxy row status
verifyProxyRowStatus(scene);

// add cells
let updateAfter: number;
addRows.forEach(row => {
Expand Down Expand Up @@ -619,3 +622,40 @@ function setRowSeriesNumberCellNeedUpdate(startUpdateRow: number, scene: Scenegr
}
}
}

function verifyProxyRowStatus(scene: Scenegraph) {
const proxy = scene.proxy;
const { rowStart, rowEnd, rowLimit, totalRow } = proxy;

if (rowStart > rowEnd) {
// 当前维护行全部清空, 重置proxy row状态
proxy.rowStart = scene.table.columnHeaderLevelCount;
proxy.rowEnd = Math.min(totalRow, proxy.rowStart + rowLimit - 1);
proxy.currentRow = 0;

return;
}

// 当前维护行部分清空,并且rowEnd向下已经超出范围,rowStart 需要向上更新
if (rowStart + rowLimit - 1 > totalRow) {
const oldRowStart = proxy.rowStart;
const newRowStart = Math.max(scene.table.columnHeaderLevelCount, totalRow - rowLimit + 1);

if (newRowStart === oldRowStart) {
return;
}
proxy.rowStart = newRowStart;
proxy.rowEnd = Math.min(totalRow, newRowStart + rowLimit - 1);
proxy.currentRow = proxy.rowEnd + 1;

const addRowCount = oldRowStart - proxy.rowStart;

// 补充缺失的空行
for (let i = 0; i < addRowCount; i++) {
addRowCellGroup(proxy.rowStart + i, scene);
}

// 更新行内容
proxy.rowUpdatePos = proxy.rowStart;
}
}
Loading