mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 10:27:44 +08:00
Feat:增加设置关联线创建时两个端点初始位置的配置
This commit is contained in:
parent
c3652331ea
commit
bb223b080c
@ -40,7 +40,7 @@ export const defaultOpt = {
|
||||
enableFreeDrag: false,
|
||||
// 水印配置
|
||||
watermarkConfig: {
|
||||
onlyExport: false,// 是否仅在导出时添加水印
|
||||
onlyExport: false, // 是否仅在导出时添加水印
|
||||
text: '',
|
||||
lineSpacing: 100,
|
||||
textSpacing: 100,
|
||||
@ -256,5 +256,12 @@ export const defaultOpt = {
|
||||
}
|
||||
}
|
||||
*/
|
||||
handleNodePasteImg: null
|
||||
handleNodePasteImg: null,
|
||||
// 默认情况下,新创建的关联线两个端点的位置是根据两个节点中心点的相对位置来计算的,如果你想固定位置,可以通过这个属性来配置
|
||||
// from和to都不传,则都自动计算,如果只传一个,另一个则会自动计算
|
||||
associativeLineInitPointsPosition: {
|
||||
// from和to可选值:left、top、bottom、right
|
||||
from: '', // 关联线起始节点上端点的位置
|
||||
to: '' // 关联线目标节点上端点的位置
|
||||
}
|
||||
}
|
||||
|
||||
@ -451,6 +451,17 @@ class AssociativeLine {
|
||||
endPoint.x,
|
||||
endPoint.y
|
||||
)
|
||||
// 检查是否存在固定位置的配置
|
||||
const { associativeLineInitPointsPosition } = this.mindMap.opt
|
||||
if (associativeLineInitPointsPosition) {
|
||||
const { from, to } = associativeLineInitPointsPosition
|
||||
if (from) {
|
||||
startPoint.dir = from
|
||||
}
|
||||
if (to) {
|
||||
endPoint.dir = to
|
||||
}
|
||||
}
|
||||
let offsetList =
|
||||
fromNode.getData('associativeLineTargetControlOffsets') || []
|
||||
// 保存的实际是控制点和端点的差值,否则当节点位置改变了,控制点还是原来的位置,连线就不对了
|
||||
|
||||
@ -223,8 +223,8 @@ export const computeNodePoints = (fromNode, toNode) => {
|
||||
toDir = 'bottom'
|
||||
} else if (offsetY > 0 && -offsetY < offsetX && offsetY > offsetX) {
|
||||
// down
|
||||
fromDir = 'right'
|
||||
toDir = 'right'
|
||||
fromDir = 'bottom'
|
||||
toDir = 'top'
|
||||
}
|
||||
return [getNodePoint(fromNode, fromDir), getNodePoint(toNode, toDir)]
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user