兼容0.4.5版本的关联线
This commit is contained in:
parent
cc331065eb
commit
de97ea9e75
@ -7,7 +7,8 @@ import {
|
|||||||
cubicBezierPath,
|
cubicBezierPath,
|
||||||
getNodePoint,
|
getNodePoint,
|
||||||
computeNodePoints,
|
computeNodePoints,
|
||||||
getNodeLinePath
|
getNodeLinePath,
|
||||||
|
getDefaultControlPointOffsets
|
||||||
} from './utils/associativeLineUtils'
|
} from './utils/associativeLineUtils'
|
||||||
|
|
||||||
// 关联线类
|
// 关联线类
|
||||||
@ -467,8 +468,14 @@ class AssociativeLine {
|
|||||||
this.controlPointMousemoveState.endPoint = endPoint
|
this.controlPointMousemoveState.endPoint = endPoint
|
||||||
let targetIndex = getAssociativeLineTargetIndex(node, toNode)
|
let targetIndex = getAssociativeLineTargetIndex(node, toNode)
|
||||||
this.controlPointMousemoveState.targetIndex = targetIndex
|
this.controlPointMousemoveState.targetIndex = targetIndex
|
||||||
let offsets =
|
let offsets = []
|
||||||
node.nodeData.data.associativeLineTargetControlOffsets[targetIndex]
|
let associativeLineTargetControlOffsets = node.nodeData.data.associativeLineTargetControlOffsets
|
||||||
|
if (!associativeLineTargetControlOffsets) {
|
||||||
|
// 兼容0.4.5版本,没有associativeLineTargetControlOffsets的情况
|
||||||
|
offsets = getDefaultControlPointOffsets(startPoint, endPoint)
|
||||||
|
} else {
|
||||||
|
offsets = associativeLineTargetControlOffsets[targetIndex]
|
||||||
|
}
|
||||||
let point1 = null
|
let point1 = null
|
||||||
let point2 = null
|
let point2 = null
|
||||||
// 拖拽的是控制点1
|
// 拖拽的是控制点1
|
||||||
@ -510,8 +517,14 @@ class AssociativeLine {
|
|||||||
let { pos, startPoint, endPoint, targetIndex } =
|
let { pos, startPoint, endPoint, targetIndex } =
|
||||||
this.controlPointMousemoveState
|
this.controlPointMousemoveState
|
||||||
let [, , node] = this.activeLine
|
let [, , node] = this.activeLine
|
||||||
let offsetList =
|
let offsetList = []
|
||||||
node.nodeData.data.associativeLineTargetControlOffsets || []
|
let associativeLineTargetControlOffsets = node.nodeData.data.associativeLineTargetControlOffsets
|
||||||
|
if (!associativeLineTargetControlOffsets) {
|
||||||
|
// 兼容0.4.5版本,没有associativeLineTargetControlOffsets的情况
|
||||||
|
offsetList[targetIndex] = getDefaultControlPointOffsets(startPoint, endPoint)
|
||||||
|
} else {
|
||||||
|
offsetList = associativeLineTargetControlOffsets
|
||||||
|
}
|
||||||
let offset1 = null
|
let offset1 = null
|
||||||
let offset2 = null
|
let offset2 = null
|
||||||
if (this.mousedownControlPointKey === 'controlPoint1') {
|
if (this.mousedownControlPointKey === 'controlPoint1') {
|
||||||
|
|||||||
@ -160,3 +160,23 @@ export const getNodeLinePath = (startPoint, endPoint, node, toNode) => {
|
|||||||
controlPoints
|
controlPoints
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取默认的控制点差值
|
||||||
|
export const getDefaultControlPointOffsets = (startPoint, endPoint) => {
|
||||||
|
let controlPoints = computeCubicBezierPathPoints(
|
||||||
|
startPoint.x,
|
||||||
|
startPoint.y,
|
||||||
|
endPoint.x,
|
||||||
|
endPoint.y
|
||||||
|
)
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
x: controlPoints[0].x - startPoint.x,
|
||||||
|
y: controlPoints[0].y - startPoint.y
|
||||||
|
},
|
||||||
|
{
|
||||||
|
x: controlPoints[1].x - endPoint.x,
|
||||||
|
y: controlPoints[1].y - endPoint.y
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user