From d99895b8457055dae0c8b7bccffc1551eae4bb1a Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Mon, 28 Aug 2023 13:47:58 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E6=94=B9=E8=8A=82?= =?UTF-8?q?=E7=82=B9hover=E5=92=8C=E6=BF=80=E6=B4=BB=E7=9F=A9=E5=BD=A2?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=BF=9E=E7=BA=BF?= =?UTF-8?q?=E5=92=8C=E8=8A=82=E7=82=B9=E4=B8=8D=E9=87=8D=E5=90=88=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/core/render/node/Node.js | 15 ++++++++------- simple-mind-map/src/core/render/node/Shape.js | 5 ++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/simple-mind-map/src/core/render/node/Node.js b/simple-mind-map/src/core/render/node/Node.js index b19b7b51..cc948ad7 100644 --- a/simple-mind-map/src/core/render/node/Node.js +++ b/simple-mind-map/src/core/render/node/Node.js @@ -260,11 +260,9 @@ class Node { this.shapePadding.paddingY = shapePaddingY // 边框宽度,因为边框是以中线向两端发散,所以边框会超出节点 const borderWidth = this.getBorderWidth() - const { hoverRectPadding } = this.mindMap.opt return { - width: _width + paddingX * 2 + shapePaddingX * 2 + borderWidth + hoverRectPadding * 2, - height: - _height + paddingY * 2 + margin + shapePaddingY * 2 + borderWidth + hoverRectPadding * 2 + width: _width + paddingX * 2 + shapePaddingX * 2 + borderWidth, + height: _height + paddingY * 2 + margin + shapePaddingY * 2 + borderWidth } } @@ -276,11 +274,11 @@ class Node { let { width, height, textContentItemMargin } = this let { paddingY } = this.getPaddingVale() const halfBorderWidth = this.getBorderWidth() / 2 - paddingY += this.shapePadding.paddingY + halfBorderWidth + hoverRectPadding + paddingY += this.shapePadding.paddingY + halfBorderWidth // 节点形状 this.shapeNode = this.shapeInstance.createShape() this.shapeNode.addClass('smm-node-shape') - this.shapeNode.translate(halfBorderWidth + hoverRectPadding, halfBorderWidth + hoverRectPadding) + this.shapeNode.translate(halfBorderWidth, halfBorderWidth) this.style.shape(this.shapeNode) this.group.add(this.shapeNode) // 渲染一个隐藏的矩形区域,用来触发展开收起按钮的显示 @@ -370,7 +368,10 @@ class Node { ) this.group.add(textContentNested) // 激活hover和激活边框 - this.hoverNode = new Rect().size(width, height).x(0).y(0) + this.hoverNode = new Rect() + .size(width + hoverRectPadding * 2, height + hoverRectPadding * 2) + .x(-hoverRectPadding) + .y(-hoverRectPadding) this.hoverNode.addClass('smm-hover-node') this.style.hoverNode(this.hoverNode, width, height) this.group.add(this.hoverNode) diff --git a/simple-mind-map/src/core/render/node/Shape.js b/simple-mind-map/src/core/render/node/Shape.js index ef85c3b0..380a8447 100644 --- a/simple-mind-map/src/core/render/node/Shape.js +++ b/simple-mind-map/src/core/render/node/Shape.js @@ -98,9 +98,8 @@ export default class Shape { getNodeSize() { const borderWidth = this.node.getBorderWidth() let { width, height } = this.node - const { hoverRectPadding } = this.node.mindMap.opt - width -= borderWidth + hoverRectPadding * 2 - height -= borderWidth + hoverRectPadding * 2 + width -= borderWidth + height -= borderWidth return { width, height