diff --git a/packages/designer/src/builtin-simulator/bem-tools/border-detecting.tsx b/packages/designer/src/builtin-simulator/bem-tools/border-detecting.tsx index 1f1735801..abc1c9cc5 100644 --- a/packages/designer/src/builtin-simulator/bem-tools/border-detecting.tsx +++ b/packages/designer/src/builtin-simulator/bem-tools/border-detecting.tsx @@ -73,6 +73,14 @@ export class BorderDetecting extends Component<{ host: BuiltinSimulatorHost }> { render() { const { host } = this.props; const { current } = this; + + const canHoverHook = current?.componentMeta.getMetadata()?.experimental?.callbacks?.onHoverHook; + const canHover = (canHoverHook && typeof canHoverHook === 'function') ? canHoverHook(current) : true; + + if (!canHover) { + return null; + } + if (!current || host.viewport.scrolling || host.liveEditing.editing) { return null; } diff --git a/packages/designer/src/builtin-simulator/bem-tools/border-resizing.tsx b/packages/designer/src/builtin-simulator/bem-tools/border-resizing.tsx index 7b47b709b..4a6b98d8f 100644 --- a/packages/designer/src/builtin-simulator/bem-tools/border-resizing.tsx +++ b/packages/designer/src/builtin-simulator/bem-tools/border-resizing.tsx @@ -82,7 +82,7 @@ export class BoxResizingForNode extends Component<{ host: BuiltinSimulatorHost; const { node } = this.props; const { designer } = this.host; - if (!instances || instances.length < 1) { + if (!instances || instances.length < 1 || this.dragging) { return null; } return ( @@ -114,9 +114,15 @@ export class BoxResizingInstance extends Component<{ // private outline: any; private willUnbind: () => any; - private outlineRight: any; - - private outlineLeft: any; + // outline of eight direction + private outlineN: any; + private outlineE: any; + private outlineS: any; + private outlineW: any; + private outlineNE: any; + private outlineNW: any; + private outlineSE: any; + private outlineSW: any; private dragEngine: DragResizeEngine; @@ -204,29 +210,33 @@ export class BoxResizingInstance extends Component<{ this.willUnbind(); } - if (!this.outlineRight && !this.outlineLeft) { + if ( + !this.outlineN && + !this.outlineE && + !this.outlineS && + !this.outlineW && + !this.outlineNE && + !this.outlineNW && + !this.outlineSE && + !this.outlineSW + ) { return; } const unBind: any[] = []; + const node = this.props.observed.node; unBind.push( - this.dragEngine.from(this.outlineRight, 'e', () => { - // if (!this.hoveringLine.hasOutline()) { - // return null; - // } - // return this.hoveringLine.getCurrentNode(); - return this.props.observed.node; - }), - ); - unBind.push( - this.dragEngine.from(this.outlineLeft, 'w', () => { - return this.props.observed.node; - // if (!this.hoveringLine.hasOutline()) { - // return null; - // } - // return this.hoveringLine.getCurrentNode(); - }), + ...[ + this.dragEngine.from(this.outlineN, 'n', () => node), + this.dragEngine.from(this.outlineE, 'e', () => node), + this.dragEngine.from(this.outlineS, 's', () => node), + this.dragEngine.from(this.outlineW, 'w', () => node), + this.dragEngine.from(this.outlineNE, 'ne', () => node), + this.dragEngine.from(this.outlineNW, 'nw', () => node), + this.dragEngine.from(this.outlineSE, 'se', () => node), + this.dragEngine.from(this.outlineSW, 'sw', () => node), + ], ); this.willUnbind = () => { @@ -252,29 +262,36 @@ export class BoxResizingInstance extends Component<{ triggerVisible = metaData.experimental.getResizingHandlers(node); } - const className = classNames('lc-borders lc-resize-box'); + const baseSideClass = 'lc-borders lc-resize-side'; + const baseCornerClass = 'lc-borders lc-resize-corner'; return (