fix(stage): 修复非多选状态下,点击选中组件切换为普通选中状态 (#254)

* fix(stage): 修复非多选状态下,点击选中组件切换为普通选中状态

* fix(stage): 修复非多选状态下,点击选中组件切换为普通选中状态

* fix(stage): 修复非多选状态下,点击选中组件切换为普通选中状态
This commit is contained in:
王明华 2022-08-12 12:55:34 +08:00 committed by GitHub
parent 78fe83bddc
commit cf9768ba96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -139,9 +139,15 @@ export default class StageCore extends EventEmitter {
setTimeout(() => this.emit('sort', data)); setTimeout(() => this.emit('sort', data));
}); });
this.multiDr.on('update', (data: UpdateEventData) => { this.multiDr
setTimeout(() => this.emit('update', data)); .on('update', (data: UpdateEventData) => {
}); setTimeout(() => this.emit('update', data));
})
.on('select', async (id: Id) => {
const el = await this.getTargetElement(id);
this.select(el); // 选中
setTimeout(() => this.emit('select', el)); // set node
});
} }
public getElementsFromPoint(event: MouseEvent) { public getElementsFromPoint(event: MouseEvent) {

View File

@ -124,6 +124,13 @@ export default class StageMultiDragResize extends EventEmitter {
}) })
.on('dragGroupEnd', () => { .on('dragGroupEnd', () => {
this.update(); this.update();
})
.on('clickGroup', (params) => {
const { inputTarget, targets } = params;
// 如果此时mask不处于多选状态下且有多个元素被选中同时点击的元素在选中元素中的其中一项代表多选态切换为该元素的单选态
if (!this.mask.isMultiSelectStatus && targets.length > 1 && targets.includes(inputTarget)) {
this.emit('select', inputTarget.id.replace(DRAG_EL_ID_PREFIX, ''));
}
}); });
} }