I'm building a logic gate application connecting the gates via jsPlumb.
To create a logic gate end point I'm doing:
jsPlumb.addEndpoint('and', {
isTarget: true,
maxConnections: 1,
anchor: 'TopRight'
},
genericStyling);
jsPlumb.addEndpoint('and', {
isTarget: true,
maxConnections: 1,
anchor: 'BottomRight'
},
genericStyling);
jsPlumb.addEndpoint('and', {
isSource: true,
maxConnections: 1,
anchor: 'Left'
},
genericStyling);
This is all working fine for adding gates and inputs to the page and drawing the lines between them but I want to preload some existing logic using:
var left = getInput(logic.left),//adds an input to the page and adds a source endpoint
right = getInput(logic.right),
gate = getGate(logic.gate); //adds a gate to the page and adds source and target endpoints
if(left && gate){
var leftLine = jsPlumb.getInstance(genericLine);
leftLine.connect({source: left, target: gate})
}
if(right && gate){
var rightLine = jsPlumb.getInstance(genericLine);
rightLine.connect({source: right, target: gate})
}
but the connect function doesn't seem to pay attention to the existing endpoints and creates it's own.
How to I draw the connection between the input source and one of the gate's targets?
我发现可以通过在添加端点和绘制连接时在端点上设置uuid来完成此操作:
jsPlumb.connect({uuids: [leftUuid, leftGateUuid]});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.