diff --git a/packages/vtable-plugins/src/table-carousel-animation.ts b/packages/vtable-plugins/src/table-carousel-animation.ts index 57f6d6397..513b6ad57 100644 --- a/packages/vtable-plugins/src/table-carousel-animation.ts +++ b/packages/vtable-plugins/src/table-carousel-animation.ts @@ -101,6 +101,9 @@ export class TableCarouselAnimationPlugin implements pluginsDefinition.IVTablePl if (customRow) { this.row = customRow.distRow; animation = customRow.animation ?? true; + } else if (this.row >= this.table.rowCount - 1) { + this.row = this.table.frozenRowCount; + animation = false; } else if (isInteger(this.row) && screenTopRow !== this.row) { this.row = this.table.frozenRowCount; animation = false; @@ -120,7 +123,6 @@ export class TableCarouselAnimationPlugin implements pluginsDefinition.IVTablePl this.willUpdateRow = false; this.updateRow(); }, - // animation ? this.animationDuration + this.animationDelay : 0 this.animationDuration + this.animationDelay ); } @@ -135,6 +137,9 @@ export class TableCarouselAnimationPlugin implements pluginsDefinition.IVTablePl if (customCol) { this.col = customCol.distCol; animation = customCol.animation ?? true; + } else if (this.col >= this.table.colCount - 1) { + this.col = this.table.frozenColCount; + animation = false; } else if (isInteger(this.col) && this.table.scenegraph.proxy.screenLeftCol !== this.col) { this.col = this.table.frozenColCount; animation = false; @@ -156,7 +161,6 @@ export class TableCarouselAnimationPlugin implements pluginsDefinition.IVTablePl this.willUpdateCol = false; this.updateCol(); }, - // animation ? this.animationDuration + this.animationDelay : 0 this.animationDuration + this.animationDelay ); } diff --git a/packages/vtable/src/core/BaseTable.ts b/packages/vtable/src/core/BaseTable.ts index 8f880d748..0c1b6ba96 100644 --- a/packages/vtable/src/core/BaseTable.ts +++ b/packages/vtable/src/core/BaseTable.ts @@ -5309,18 +5309,21 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI { } const duration = !isBoolean(animationOption) ? animationOption?.duration ?? 3000 : 3000; this.animationManager.scrollTo({ row: targetRow }, animationOption); - if (targetRowInt === targetRow) { - this._scrollToRowCorrectTimer = setTimeout(() => { - this.scrollToRow(targetRowInt, false); - }, duration); - } + this._scrollToRowCorrectTimer = setTimeout(() => { + this.scrollToRow(targetRowInt, false); + }, duration); } scrollToCol(col: number, animationOption?: ITableAnimationOption | boolean) { if (!animationOption) { this.scrollToCell({ col }); return; } + const duration = !isBoolean(animationOption) ? animationOption?.duration ?? 3000 : 3000; this.animationManager.scrollTo({ col }, animationOption); + setTimeout(() => { + this.scrollToCell({ col: Math.floor(col) }); + this.render(); + }, duration); } /** * 滚动到具体某个单元格位置 diff --git a/packages/vtable/src/core/animation.ts b/packages/vtable/src/core/animation.ts index 32fd437f3..e34f48b2a 100644 --- a/packages/vtable/src/core/animation.ts +++ b/packages/vtable/src/core/animation.ts @@ -10,11 +10,11 @@ function isInteger(value: number) { class Animateaaa extends ACustomAnimate { onUpdate(end: boolean, ratio: number, out: Record): void { if (this.from.x !== this.to.x) { - const x = end ? this.to.x : this.from.x + Math.floor((this.to.x - this.from.x) * ratio); + const x = end ? this.to.x : this.from.x + Math.round((this.to.x - this.from.x) * ratio); this.params.table.scrollLeft = x; } if (this.from.y !== this.to.y) { - const y = end ? this.to.y : this.from.y + Math.floor((this.to.y - this.from.y) * ratio); + const y = end ? this.to.y : this.from.y + Math.round((this.to.y - this.from.y) * ratio); this.params.table.scrollTop = y; } }