The view for the joint.dia.Link model. It inherits from joint.dia.CellView and is responsible for:
To find the view associated with a specific link model, use the paper.findViewByModel()
method:
var linkView = paper.findViewByModel(link);
It is possible to use a custom default link view for all your links in a paper. This can be set up via the linkView
option on the paper object. Several options in joint.dia.LinkView
may be overridden in a custom LinkView:
105
.longLinkLength
). Defaults to false
.doubleLinkTools: true
, render link tools on both ends of the link. Defaults to 155
.40
.longLinkLength
and doubleLinkTools: true
. Defaults to 65
.A custom LinkView type may also override default LinkView event handlers, or provide new ones. It may be necessary to modify the interactive
paper option to prevent interference from builtin event handlers (most notably vertexAdd
which listens for pointerdown events).
Example:
var CustomLinkView = joint.dia.LinkView.extend({
// custom interactions:
pointerdblclick: function(evt, x, y) {
this.addVertex(x, y);
},
contextmenu: function(evt, x, y) {
this.addLabel(x, y);
},
// custom options:
options: joint.util.defaults({
doubleLinkTools: true,
}, joint.dia.LinkView.prototype.options)
});
var paper = new joint.dia.Paper({
//...
linkView: CustomLinkView,
interactive: { vertexAdd: false } // disable default vertexAdd interaction
});