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: add tolerance for scroll in _disableColumnAndRowSizeRound mode",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
10 changes: 8 additions & 2 deletions packages/vtable/src/scenegraph/component/table-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,13 @@ export class TableComponent {
const frozenColsWidth = this.table.getFrozenColsWidth();
const bottomFrozenRowsHeight = this.table.getBottomFrozenRowsHeight();
const rightFrozenColsWidth = this.table.getRightFrozenColsWidth();
if (totalWidth > tableWidth) {

// _disableColumnAndRowSizeRound环境中,可能出现
// getAllColsWidth/getAllRowsHeight(A) + getAllColsWidth/getAllRowsHeight(B) < getAllColsWidth/getAllRowsHeight(A+B)
// (由于小数在取数时被省略)
// 这里加入tolerance,避免出现无用滚动
const sizeTolerance = this.table.options.customConfig?._disableColumnAndRowSizeRound ? 1 : 0;
if (totalWidth > tableWidth + sizeTolerance) {
const y = Math.min(tableHeight, totalHeight);
const rangeEnd = Math.max(0.05, (tableWidth - frozenColsWidth) / (totalWidth - frozenColsWidth));

Expand Down Expand Up @@ -384,7 +390,7 @@ export class TableComponent {
});
}

if (totalHeight > tableHeight) {
if (totalHeight > tableHeight + sizeTolerance) {
const x = Math.min(tableWidth, totalWidth);
const rangeEnd = Math.max(0.05, (tableHeight - frozenRowsHeight) / (totalHeight - frozenRowsHeight));

Expand Down
15 changes: 13 additions & 2 deletions packages/vtable/src/state/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,12 @@ export class StateManager {
setScrollTop(top: number) {
// 矫正top值范围
const totalHeight = this.table.getAllRowsHeight();
top = Math.max(0, Math.min(top, totalHeight - this.table.scenegraph.height));
// _disableColumnAndRowSizeRound环境中,可能出现
// getAllColsWidth/getAllRowsHeight(A) + getAllColsWidth/getAllRowsHeight(B) < getAllColsWidth/getAllRowsHeight(A+B)
// (由于小数在取数时被省略)
// 这里加入tolerance,避免出现无用滚动
const sizeTolerance = this.table.options.customConfig?._disableColumnAndRowSizeRound ? 1 : 0;
top = Math.max(0, Math.min(top, totalHeight - this.table.scenegraph.height - sizeTolerance));
top = Math.ceil(top);
// 滚动期间清空选中清空 如果调用接口hover状态需要保留,但是如果不调用updateHoverPos透视图处于hover状态的图就不能及时更新 所以这里单独判断了isPivotChart
if (top !== this.scroll.verticalBarPos || this.table.isPivotChart()) {
Expand Down Expand Up @@ -943,7 +948,13 @@ export class StateManager {
const totalWidth = this.table.getAllColsWidth();
const frozenWidth = this.table.getFrozenColsWidth();

left = Math.max(0, Math.min(left, totalWidth - this.table.scenegraph.width));
// _disableColumnAndRowSizeRound环境中,可能出现
// getAllColsWidth/getAllRowsHeight(A) + getAllColsWidth/getAllRowsHeight(B) < getAllColsWidth/getAllRowsHeight(A+B)
// (由于小数在取数时被省略)
// 这里加入tolerance,避免出现无用滚动
const sizeTolerance = this.table.options.customConfig?._disableColumnAndRowSizeRound ? 1 : 0;

left = Math.max(0, Math.min(left, totalWidth - this.table.scenegraph.width - sizeTolerance));
left = Math.ceil(left);
// 滚动期间清空选中清空
if (left !== this.scroll.horizontalBarPos) {
Expand Down