Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2040 bug last col resize width #2043

Merged
merged 2 commits into from
Jul 5, 2024
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,11 @@
{
"changes": [
{
"comment": "fix: last column resize width error #2040\n\n",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "892739385@qq.com"
}
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
Loading