New link anchor functions can be defined in the joint.linkAnchors
namespace (e.g. joint.linkAnchors.myLinkAnchor
) or passed directly as a function to the linkAnchor
property of link source/target (or to the defaultLinkAnchor
option of a paper).
In either case, the link anchor function must return the link anchor as a Point. The function is expected to have the form function(endView, endMagnet, anchorReference, args)
:
endView | dia.LinkView | The LinkView to which we are connecting. The Link model can be accessed as endView.model ; this may be useful for writing conditional logic based on link attributes. |
---|---|---|
endMagnet | null | (Not used) This argument is only present to ensure that the signature of custom linkAnchor methods is the same as the signature of custom anchor methods. |
anchorReference | g.Point | A reference to another component of the link path that may be necessary to find this anchor point. If we are calling this method for a source anchor, it is the first vertex; if there are no vertices, it is the target anchor. If we are calling this method for a target anchor, it is the last vertex; if there are no vertices, it is the source anchor... |
SVGElement | ...if the anchor in question does not exist (yet), it is that link end's magnet. (The built-in methods usually use this element's center point as reference.) | |
args | object | An object with additional optional arguments passed to the link anchor method by the user when it was called (the args property). |