How can I connect multiple targets from a single source?

泄露秘密 提交于 2019-12-13 05:29:45

问题


I am using this code to connect a single object one another object and this works fine. Could anybody help me to modify this to link a single object to multiple objects.

var start = 'logo';
var end = 'link';    
jsPlumb.connect({
    source:start,
    target:end,
    connector: [ "Flowchart", {cornerRadius:1} ],
    paintStyle:{
        lineWidth:5,
        strokeStyle:'#3E2522' },
    anchors: [[1.02, 0.5, 0, 1], [-0.02, 0.5, 0, 0]],
    endpointStyle: { radius:0.5 }
});

回答1:


Store all the id's of the target elements in an array and then you can loop the above code for your result:

var start = 'logo';
var end = ['link1','link2','link3',....];    

for(var i=0;i<end.length;i++){
    jsPlumb.connect({
        source:start,
        target:end[i],
        connector: [ "Flowchart", {cornerRadius:1} ],
        paintStyle:{
            lineWidth:5, strokeStyle:'#3E2522' },
        anchors: [[1.02, 0.5, 0, 1], [-0.02, 0.5, 0, 0]],
        endpointStyle: { radius:0.5 }
    })
}


来源:https://stackoverflow.com/questions/20582995/how-can-i-connect-multiple-targets-from-a-single-source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!