use*_*695 8 javascript jointjs
我想通过双击链接为链接添加标签.所以这是我的尝试:
paper.on({
'cell:pointerdblclick': function(cellView, event, x, y){
if (cellView.model.isLink()) {
cellView.model.label(0, {
position: .5,
attrs: {
rect: { fill: 'white' },
text: { text: 'my label' }
}
});
}
},
});
Run Code Online (Sandbox Code Playgroud)
问题是,通过双击,还可以同时创建一个顶点.我怎么能防止这种情况?
或者让用户为链接添加标签的另一种简单方法是什么?
use*_*987 14
如文档(http://jointjs.com/api#joint.dia.LinkView:addVertex)所示,只需将此部分添加到joint.dia.Paper:
interactive: function(cellView) {
if (cellView.model instanceof joint.dia.Link) {
// Disable the default vertex add functionality on pointerdown.
return { vertexAdd: false };
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1950 次 |
| 最近记录: |