dia.link and dia.element #2028
-
Hello everyone, I'm facing an issue with JointJS. I have an element called UMLClass, which consists of three rectangles (Name, Methods, and Attributes). When I try to connect this element with a link, it always attaches in the middle of the element. However, all my other elements attach at the optimal position on the outside based on their position. Does anyone have any suggestions on how to fix this? Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This is the default behavior of the Boundary connection point. The connection point function tries to find the geometry of the magnet first. If the magnet is a You can use a custom connection point that defines different selector for different elements (as we do in the Kitchen Sink application). defaultConnectionPoint: function(endPathSegmentLine, endView, endMagnet) {
return joint.connectionPoints.boundary.call(this, endPathSegmentLine, endView, endMagnet, {
selector: endView.model.get('type') === 'uml.Class' ? 'root' : 'body'
});
} See example. There is an unofficial way to disable the smart geometry lookup. defaultConnectionPoint: { name: 'boundary', args: { selector: [] }} Using this along with magnetSelector attributes seem to be the most elegant way. See modified example We'll add an official way to disable it soon. Since we introduced |
Beta Was this translation helpful? Give feedback.
This is the default behavior of the Boundary connection point. The connection point function tries to find the geometry of the magnet first. If the magnet is a
<g/>
, it looks inside for any graphics element such as<rect/>
, `. In case of UML Class, there are 3 rectangles and the connection point picks the first one.You can use a custom connection point that defines different selector for different elements (as we do in the Kitchen Sink application).