问题
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