【发布时间】:2015-05-15 19:16:14
【问题描述】:
我试图避免链接在空间中结束,我只想允许链接将一个元素与另一个元素连接起来。我当前的代码是:
new joint.shapes.basic.Rect({
id: id,
size: {
width: width,
height: height
},
attrs: {
text: {
text: label,
'font-size': letterSize
},
rect: {
width: width,
height: height,
rx: 5,
ry: 5,
stroke: '#555',
'magnet': true
}
}
});
对于论文:
var paper = new joint.dia.Paper({
el: $('#paper-basic'),
width: 1250,
height: 1000,
model: graph,
gridSize: 1,
validateConnection: function(cellViewS, magnetS, cellViewT, magnetT, end, linkView) {
// Prevent linking from output ports to input ports within one element.
if (cellViewS === cellViewT) return false;
// Prevent linking to input ports.
return magnetT;
},
markAvailable: true
});
如何要求每个链接都有源和目标?也许通过扩展validateConnection?
【问题讨论】:
标签: jointjs