Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复nodeUseLineStyle风格时连线位置与根节点位置异常、修复fit功能缩放后没有重新设置几何信息导致的定位异常 #638

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion simple-mind-map/src/core/render/node/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,9 @@ class Node {
// }
// 如果节点位置没有变化,则返回
if (this.left === t.translateX && this.top === t.translateY) return
this.group.translate(this.left - t.translateX, this.top - t.translateY)
const isRootAndLineStyle = this.isRoot && this.mindMap.opt?.themeConfig?.nodeUseLineStyle
const y = isRootAndLineStyle ? this.top - t.translateY + this.height / 2 : this.top - t.translateY
this.group.translate(this.left - t.translateX, y)
}

// 获取节点相当于画布的位置
Expand Down
3 changes: 3 additions & 0 deletions simple-mind-map/src/core/view/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ class View {
newScale = newWidth / drawWidth
}
this.setScale(newScale)
// 重新计算缩放后的位置、几何信息
+ this.mindMap.getElRectInfo()

const newRect = getRbox() || draw.rbox()
// 需要考虑画布容器距浏览器窗口左上角的距离
newRect.x -= this.mindMap.elRect.left
Expand Down
6 changes: 3 additions & 3 deletions simple-mind-map/src/layouts/LogicalStructure.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class LogicalStructure extends Base {
let y2 = item.top + item.height / 2
// 节点使用横线风格,需要额外渲染横线
let nodeUseLineStyleOffset = nodeUseLineStyle ? item.width : 0
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
y1 = nodeUseLineStyle ? y1 + height / 2 : y1
y2 = nodeUseLineStyle ? y2 + item.height / 2 : y2
let path = this.createFoldLine([
[x1, y1],
Expand Down Expand Up @@ -206,7 +206,7 @@ class LogicalStructure extends Base {
let y1 = top + height / 2
let x2 = item.left
let y2 = item.top + item.height / 2
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
y1 = nodeUseLineStyle ? y1 + height / 2 : y1
y2 = nodeUseLineStyle ? y2 + item.height / 2 : y2
// 节点使用横线风格,需要额外渲染横线
let nodeUseLineStylePath = nodeUseLineStyle
Expand Down Expand Up @@ -243,7 +243,7 @@ class LogicalStructure extends Base {
let x2 = item.left
let y2 = item.top + item.height / 2
let path = ''
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
y1 = nodeUseLineStyle ? y1 + height / 2 : y1
y2 = nodeUseLineStyle ? y2 + item.height / 2 : y2
// 节点使用横线风格,需要额外渲染横线
let nodeUseLineStylePath = nodeUseLineStyle
Expand Down
6 changes: 3 additions & 3 deletions simple-mind-map/src/layouts/MindMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class MindMap extends Base {
? item.left + item.width
: item.left
let y2 = item.top + item.height / 2
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
y1 = nodeUseLineStyle ? y1 + height / 2 : y1
y2 = nodeUseLineStyle ? y2 + item.height / 2 : y2
let path = this.createFoldLine([
[x1, y1],
Expand Down Expand Up @@ -274,7 +274,7 @@ class MindMap extends Base {
? item.left + item.width
: item.left
let y2 = item.top + item.height / 2
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
y1 = nodeUseLineStyle ? y1 + height / 2 : y1
y2 = nodeUseLineStyle ? y2 + item.height / 2 : y2
// 节点使用横线风格,需要额外渲染横线
let nodeUseLineStylePath = ''
Expand Down Expand Up @@ -321,7 +321,7 @@ class MindMap extends Base {
: item.left
let y2 = item.top + item.height / 2
let path = ''
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
y1 = nodeUseLineStyle ? y1 + height / 2 : y1
y2 = nodeUseLineStyle ? y2 + item.height / 2 : y2
// 节点使用横线风格,需要额外渲染横线
let nodeUseLineStylePath = ''
Expand Down