我一直在尝试通过 jsplumb.connect() 建立编程连接,到目前为止,我已经能够通过维护源和 anchor 信息来连接元素。
但是,端点会在分离时中断连接,而不是允许我在不将自身与位置分离的情况下绘制另一个连接。
我正在使用的 jsplumb.connect 代码:
connection = plumb.connect({
source:parsed_conn_list[j].source,
target:parsed_conn_list[j].target,
anchors:parsed_conn_list[j].anchors,
reattach:true,
paintStyle:{lineWidth: 4, strokeStyle: '#000'},
connector: ["Bezier", { curviness: 70 }],
deleteEndpointsOnDetach:false,
overlays:[
[ "Arrow", { width:14, length:14, location:0.93, id:"arrow" } ]
]
});
任何帮助将不胜感激。
编辑:
大家好,这是我用来添加端点而不是仅添加源/目标 ID 的当前工作代码:
final_source = plumb.getEndpoints(parsed_conn_list[j].source)[0]
final_target = plumb.getEndpoints(parsed_conn_list[j].target)[0]
connection = plumb.connect({
source:final_source,
target:final_target,
//anchors:parsed_conn_list[j].anchors,
reattach:true,
paintStyle:{lineWidth: 4, strokeStyle: '#000'},
connector: ["Bezier", { curviness: 70 }],
deleteEndpointsOnDetach:false,
overlays:[
[ "Arrow", { width:14, length:14, location:0.93, id:"arrow" } ]
]
});
最佳答案
我喜欢的方式是:
- 在源元素和目标元素上创建端点。
- 使用端点而不是源/目标 ID 调用 jsPlumb.connect。
- 现在,当您断开连接时,端点不会被删除。
关于javascript - 如何在使用 jsplumb.connect() 时保留端点信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32253461/