gpt4 book ai didi

JointJS:创建链接时需要目标元素

转载 作者:行者123 更新时间:2023-12-01 08:54:36 25 4
gpt4 key购买 nike

我试图避免链接在空间中结束,我只想允许链接将一个元素与另一个元素连接起来。我当前的代码是:

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

最佳答案

如果这仍然相关,现在在 Paper 元素上有一个名为 linkPinning 的选项:

http://jointjs.com/api#dia.Paper.prototype.options

linkPinning - when set to true (the default), links can be pinned to the paper meaning a source or target of a link can be a point. If you do not want to let the user to drag a link and drop it somewhere in a blank paper area, set this to false. The effect is that the link will be returned to its original position whenever the user drops it somewhere in a blank paper area.

关于JointJS:创建链接时需要目标元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30267165/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com