From 8fba929fb8c0567e195ca9ecdd90f9d677c0aa3e Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Thu, 13 Apr 2023 19:49:56 +0800 Subject: [PATCH] feat: handle boundary when dragging elements --- src/editor/core/event/handlers/mouseup.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/editor/core/event/handlers/mouseup.ts b/src/editor/core/event/handlers/mouseup.ts index a55b460..2a24aed 100644 --- a/src/editor/core/event/handlers/mouseup.ts +++ b/src/editor/core/event/handlers/mouseup.ts @@ -29,6 +29,18 @@ export function mouseup(evt: MouseEvent, host: CanvasEvent) { const cacheElementList = host.cacheElementList! const cachePositionList = host.cachePositionList! const range = rangeManager.getRange() + // 是否需要拖拽-位置发生改变 + if (range.startIndex >= cacheRange.startIndex && range.endIndex <= cacheRange.endIndex) { + rangeManager.replaceRange({ + ...cacheRange + }) + draw.render({ + isSetCursor: false, + isCompute: false, + isSubmitHistory: false + }) + return + } // 是否是不可拖拽的控件结构元素 const dragElementList = cacheElementList.slice(cacheRange.startIndex + 1, cacheRange.endIndex + 1) const isContainControl = dragElementList.find(element => element.type === ElementType.CONTROL)