From 2738d3ae4cef76aa9a7d85ab1ab2d925ba0df5f8 Mon Sep 17 00:00:00 2001 From: zhaopeng <41977379+zp190265950@users.noreply.github.com> Date: Wed, 15 May 2024 21:08:11 +0800 Subject: [PATCH] fix: dragging to adjust td width boundary error #569 --- .../core/draw/particle/table/TableTool.ts | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/editor/core/draw/particle/table/TableTool.ts b/src/editor/core/draw/particle/table/TableTool.ts index 5605af1..14e0481 100644 --- a/src/editor/core/draw/particle/table/TableTool.ts +++ b/src/editor/core/draw/particle/table/TableTool.ts @@ -285,25 +285,27 @@ export class TableTool { 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] - // 下一列减去偏移量 - if (c === index + 1) { - moveTableWidth -= dx + // 开始移动,只有表格的最后一列线才会改变表格的宽度,其他场景不用计算表格超出 + if (index === colgroup.length - 1) { + let moveTableWidth = 0 + for (let c = 0; c < colgroup.length; c++) { + const group = colgroup[c] + // 下一列减去偏移量 + if (c === index + 1) { + moveTableWidth -= dx + } + // 当前列加上偏移量 + if (c === index) { + moveTableWidth += moveColWidth + } + if (c !== index) { + moveTableWidth += group.width + } } - // 当前列加上偏移量 - if (c === index) { - moveTableWidth += moveColWidth + if (moveTableWidth > innerWidth) { + const tableWidth = element.width! + dx = innerWidth - tableWidth } - if (c !== index) { - moveTableWidth += group.width - } - } - if (moveTableWidth > innerWidth) { - const tableWidth = element.width! - dx = innerWidth - tableWidth } if (dx) { // 当前列增加,后列减少