Skip to content

Commit

Permalink
Merge pull request #2043 from VisActor/2040-bug-lastColResizeWidth
Browse files Browse the repository at this point in the history
2040 bug last col resize width
  • Loading branch information
fangsmile committed Jul 5, 2024
2 parents d3be757 + 1f805d0 commit 5368718
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: last column resize width error #2040\n\n",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "[email protected]"
}
6 changes: 6 additions & 0 deletions packages/vtable/src/event/listener/container-dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { handleWhell } from '../scroll';
import { browser } from '../../tools/helper';
import type { EventManager } from '../event';
import { getPixelRatio } from '../../tools/pixel-ratio';
import { endResizeCol, endResizeRow } from './table-group';

export function bindContainerDomListener(eventManager: EventManager) {
const table = eventManager.table;
Expand Down Expand Up @@ -512,6 +513,11 @@ export function bindContainerDomListener(eventManager: EventManager) {
table.eventManager.isDown = false;
table.eventManager.isDraging = false;
table.eventManager.inertiaScroll.endInertia();
if (stateManager.isResizeCol()) {
endResizeCol(table);
} else if (stateManager.isResizeRow()) {
endResizeRow(table);
}
};
eventManager.globalEventListeners.push({
name: 'pointerup',
Expand Down
4 changes: 2 additions & 2 deletions packages/vtable/src/event/listener/table-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ export function bindGesture(eventManager: EventManager) {
dblclickHandler(e, table);
});
}
function endResizeCol(table: BaseTableAPI) {
export function endResizeCol(table: BaseTableAPI) {
table.stateManager.endResizeCol();
// textStick 依赖了这个事件 所以一定要触发RESIZE_COLUMN_END
// if ((table as any).hasListeners(TABLE_EVENT_TYPE.RESIZE_COLUMN_END)) {
Expand All @@ -974,7 +974,7 @@ function endResizeCol(table: BaseTableAPI) {
// }
}

function endResizeRow(table: BaseTableAPI) {
export function endResizeRow(table: BaseTableAPI) {
table.stateManager.endResizeRow();

table.fireListeners(TABLE_EVENT_TYPE.RESIZE_ROW_END, {
Expand Down
2 changes: 1 addition & 1 deletion packages/vtable/src/scenegraph/scenegraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ export class Scenegraph {
const drawRange = this.table.getDrawRange();
if (abstractY >= drawRange.top && abstractY <= drawRange.bottom) {
// to do: 处理最后一列外调整列宽
cell = this.table.getCellAt(abstractX - offset, abstractY);
cell = this.table.getCellAtRelativePosition(abstractX - offset, abstractY);
return cell;
}
return { col: -1, row: -1 };
Expand Down
6 changes: 4 additions & 2 deletions packages/vtable/src/ts-types/base-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ import type {
WidthAdaptiveModeDef,
HeightAdaptiveModeDef,
ColumnInfo,
RowInfo
RowInfo,
CellAddressWithBound
} from '.';
import type { TooltipOptions } from './tooltip';
import type { IWrapTextGraphicAttribute } from '../scenegraph/graphic/text';
Expand Down Expand Up @@ -624,7 +625,8 @@ export interface BaseTableAPI {
isFrozenCell: (col: number, row: number) => { row: boolean; col: boolean } | null;
getRowAt: (absoluteY: number) => { top: number; row: number; bottom: number };
getColAt: (absoluteX: number) => { left: number; col: number; right: number };
getCellAt: (absoluteX: number, absoluteY: number) => CellAddress;
getCellAt: (absoluteX: number, absoluteY: number) => CellAddressWithBound;
getCellAtRelativePosition: (absoluteX: number, absoluteY: number) => CellAddressWithBound;
_makeVisibleCell: (col: number, row: number) => void;
// setFocusCursor(col: number, row: number): void;
// focusCell(col: number, row: number): void;
Expand Down

0 comments on commit 5368718

Please sign in to comment.