fix(stage): 当选中的组件与上一次选中的组件有重叠时,选中后的下一个click事件丢失

This commit is contained in:
roymondchen 2022-09-14 18:31:42 +08:00 committed by jia000
parent 45be838f20
commit 33a09cccc7
3 changed files with 13 additions and 4 deletions

View File

@ -96,6 +96,11 @@ export default class StageDragResize extends EventEmitter {
const oldTarget = this.target;
this.target = el;
if (!this.dragEl) {
this.dragEl = globalThis.document.createElement('div');
this.container.append(this.dragEl);
}
// 从不能拖动到能拖动的节点之间切换要重新创建moveable不然dragStart不生效
if (!this.moveable || this.target !== oldTarget) {
this.init(el);
@ -157,6 +162,7 @@ export default class StageDragResize extends EventEmitter {
public clearSelectStatus(): void {
if (!this.moveable) return;
this.destroyDragEl();
this.dragEl = undefined;
this.moveable.target = null;
this.moveable.updateTarget();
}
@ -184,9 +190,11 @@ export default class StageDragResize extends EventEmitter {
this.mode = getMode(el);
this.destroyGhostEl();
this.destroyDragEl();
this.dragEl = globalThis.document.createElement('div');
this.container.append(this.dragEl);
if (!this.dragEl) {
return;
}
this.dragEl.style.cssText = getTargetElStyle(el);
this.dragEl.id = `${DRAG_EL_ID_PREFIX}${el.id}`;

View File

@ -57,7 +57,7 @@ export default class TargetCalibrate extends EventEmitter {
top: ${top}px;
width: ${el.clientWidth}px;
height: ${el.clientHeight}px;
z-index: ${ZIndex.DRAG_EL};
z-index: ${ZIndex.HIGHLIGHT_EL};
`;
this.operationEl.id = `${prefix}${el.id}`;

View File

@ -48,6 +48,7 @@ export enum ZIndex {
SELECTED_EL = '666',
GHOST_EL = '700',
DRAG_EL = '9',
HIGHLIGHT_EL = '8',
}
/** 鼠标按键 */