Skip to content

Commit

Permalink
fix: drag table border to change size #160
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Mar 25, 2023
1 parent ca5c4be commit fda18d9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/editor/core/draw/particle/table/TableTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class TableTool {
this._mousedown({
evt,
element,
index: td.rowIndex!,
index: td.rowIndex! + td.rowspan - 1,
order: TableOrder.ROW
})
}
Expand All @@ -181,7 +181,7 @@ export class TableTool {
this._mousedown({
evt,
element,
index: td.colIndex!,
index: td.colIndex! + td.colspan - 1,
order: TableOrder.COL
})
}
Expand Down Expand Up @@ -253,14 +253,17 @@ export class TableTool {
// 宽度分配
const innerWidth = this.draw.getInnerWidth()
const curColWidth = colgroup[index].width
// 最小移动距离计算
const moveColWidth = curColWidth + dx
const nextColWidth = colgroup[index + 1]?.width || 0
// 如果移动距离小于最小宽度,或者大于当前列和下一列宽度之和则移动最小宽度
if (moveColWidth < this.MIN_TD_WIDTH || moveColWidth > curColWidth + nextColWidth) {
// 最小移动距离计算-如果向左移动:使单元格小于最小宽度,则减少移动量
if (dx < 0 && curColWidth + dx < this.MIN_TD_WIDTH) {
dx = this.MIN_TD_WIDTH - curColWidth
}
// 最大移动距离计算
// 最大移动距离计算-如果向右移动:使后面一个单元格小于最小宽度,则减少移动量
const nextColWidth = colgroup[index + 1]?.width
if (dx > 0 && nextColWidth && nextColWidth - dx < this.MIN_TD_WIDTH) {
dx = nextColWidth - this.MIN_TD_WIDTH
}
const moveColWidth = curColWidth + dx
// 开始移动
let moveTableWidth = 0
for (let c = 0; c < colgroup.length; c++) {
const group = colgroup[c]
Expand Down

0 comments on commit fda18d9

Please sign in to comment.