Fix:修复节点边框会重合的问题
This commit is contained in:
parent
fb681de1f5
commit
a4dc9210b3
@ -257,9 +257,11 @@ class Node {
|
|||||||
this.shapeInstance.getShapePadding(_width, _height, paddingX, paddingY)
|
this.shapeInstance.getShapePadding(_width, _height, paddingX, paddingY)
|
||||||
this.shapePadding.paddingX = shapePaddingX
|
this.shapePadding.paddingX = shapePaddingX
|
||||||
this.shapePadding.paddingY = shapePaddingY
|
this.shapePadding.paddingY = shapePaddingY
|
||||||
|
// 边框宽度,因为边框是以中线向两端发散,所以边框会超出节点
|
||||||
|
const borderWidth = this.getBorderWidth()
|
||||||
return {
|
return {
|
||||||
width: _width + paddingX * 2 + shapePaddingX * 2,
|
width: _width + paddingX * 2 + shapePaddingX * 2 + borderWidth,
|
||||||
height: _height + paddingY * 2 + margin + shapePaddingY * 2
|
height: _height + paddingY * 2 + margin + shapePaddingY * 2 + borderWidth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,10 +271,12 @@ class Node {
|
|||||||
this.group.clear()
|
this.group.clear()
|
||||||
let { width, height, textContentItemMargin } = this
|
let { width, height, textContentItemMargin } = this
|
||||||
let { paddingY } = this.getPaddingVale()
|
let { paddingY } = this.getPaddingVale()
|
||||||
paddingY += this.shapePadding.paddingY
|
const halfBorderWidth = this.getBorderWidth() / 2
|
||||||
|
paddingY += this.shapePadding.paddingY + halfBorderWidth
|
||||||
// 节点形状
|
// 节点形状
|
||||||
this.shapeNode = this.shapeInstance.createShape()
|
this.shapeNode = this.shapeInstance.createShape()
|
||||||
this.shapeNode.addClass('smm-node-shape')
|
this.shapeNode.addClass('smm-node-shape')
|
||||||
|
this.shapeNode.translate(halfBorderWidth, halfBorderWidth)
|
||||||
this.group.add(this.shapeNode)
|
this.group.add(this.shapeNode)
|
||||||
this.updateNodeShape()
|
this.updateNodeShape()
|
||||||
// 渲染一个隐藏的矩形区域,用来触发展开收起按钮的显示
|
// 渲染一个隐藏的矩形区域,用来触发展开收起按钮的显示
|
||||||
@ -827,6 +831,11 @@ class Node {
|
|||||||
) // 父级
|
) // 父级
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取节点非节点状态的边框大小
|
||||||
|
getBorderWidth() {
|
||||||
|
return this.style.merge('borderWidth', false, false) || 0
|
||||||
|
}
|
||||||
|
|
||||||
// 获取数据
|
// 获取数据
|
||||||
getData(key) {
|
getData(key) {
|
||||||
return key ? this.nodeData.data[key] || '' : this.nodeData.data
|
return key ? this.nodeData.data[key] || '' : this.nodeData.data
|
||||||
|
|||||||
@ -62,7 +62,10 @@ export default class Shape {
|
|||||||
// 创建形状节点
|
// 创建形状节点
|
||||||
createShape() {
|
createShape() {
|
||||||
const shape = this.node.getShape()
|
const shape = this.node.getShape()
|
||||||
|
const borderWidth = this.node.getBorderWidth()
|
||||||
let { width, height } = this.node
|
let { width, height } = this.node
|
||||||
|
width -= borderWidth
|
||||||
|
height -= borderWidth
|
||||||
let node = null
|
let node = null
|
||||||
// 矩形
|
// 矩形
|
||||||
if (shape === CONSTANTS.SHAPE.RECTANGLE) {
|
if (shape === CONSTANTS.SHAPE.RECTANGLE) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user