feat: 支持设置是否允许画布鼠标事件的冒泡

This commit is contained in:
力皓 2021-06-10 16:05:24 +08:00
parent c8e2f9d8ef
commit f5e8239c4d

View File

@ -641,14 +641,16 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
*/ */
setupDetecting() { setupDetecting() {
const doc = this.contentDocument!; const doc = this.contentDocument!;
const { detecting } = this.designer; const { detecting, dragon } = this.designer;
const hover = (e: MouseEvent) => { const hover = (e: MouseEvent) => {
if (!detecting.enable || this.designMode !== 'design') { if (!detecting.enable || this.designMode !== 'design') {
return; return;
} }
const nodeInst = this.getNodeInstanceFromElement(e.target as Element); const nodeInst = this.getNodeInstanceFromElement(e.target as Element);
detecting.capture(nodeInst?.node || null); detecting.capture(nodeInst?.node || null);
if (!engineConfig.get('enableMouseEventPropagationInCanvas', false) || dragon.dragging) {
e.stopPropagation(); e.stopPropagation();
}
}; };
const leave = () => detecting.leave(this.project.currentDocument); const leave = () => detecting.leave(this.project.currentDocument);
@ -659,7 +661,9 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
doc.addEventListener( doc.addEventListener(
'mousemove', 'mousemove',
(e: Event) => { (e: Event) => {
if (!engineConfig.get('enableMouseEventPropagationInCanvas', false) || dragon.dragging) {
e.stopPropagation(); e.stopPropagation();
}
}, },
true, true,
); );