Skip to content

Commit f727aa5

Browse files
Rui-Sunskie1997
authored andcommitted
fix: correct scroll position calculation for fractional row indices
1 parent f935c15 commit f727aa5

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

packages/vtable/src/core/BaseTable.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4992,7 +4992,12 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
49924992
if (isValid(cellAddr.row) && cellAddr.row >= this.frozenRowCount) {
49934993
const frozenHeight = this.getFrozenRowsHeight();
49944994
// const top = this.getRowsHeight(0, cellAddr.row - 1);
4995-
const top = this.internalProps._rowHeightsMap.getSumInRange(0, cellAddr.row - 1);
4995+
const rowInt = Math.floor(cellAddr.row);
4996+
const rowFloat = cellAddr.row - rowInt;
4997+
let top = this.internalProps._rowHeightsMap.getSumInRange(0, rowInt - 1);
4998+
if (rowFloat > 0) {
4999+
top += (this.internalProps._rowHeightsMap.get(rowInt) ?? this.getRowHeight(rowInt)) * rowFloat;
5000+
}
49965001
this.scrollTop = Math.min(top - frozenHeight, this.getAllRowsHeight() - drawRange.height);
49975002
}
49985003
this.render();

packages/vtable/src/core/animation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ export class TableAnimationManager {
7979
const to = {
8080
x: isNumber(col) ? left - this.table.getFrozenColsWidth() : this.table.scrollLeft,
8181
y: isNumber(row) ? top - this.table.getFrozenRowsHeight() : this.table.scrollTop,
82-
targetCol: colInt ?? -1,
83-
targetRow: rowInt ?? -1
82+
targetCol: col ?? -1,
83+
targetRow: row ?? -1
8484
};
8585
const duration = !isBoolean(animationOption) ? animationOption?.duration ?? 3000 : animationOption ? 3000 : 0;
8686
const easing = !isBoolean(animationOption) ? animationOption?.easing ?? 'linear' : animationOption ? 'linear' : '';

0 commit comments

Comments
 (0)