Ports Detaching from Diagram Elements After Resizing Width or Height #3019
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
When a port group uses the default positioning algorithms, JointJS places the ports relative to the element’s bounding box - i.e., the rectangle defined by the element’s size attribute. How exactly does your shape definition look like? Are you certain you need to be using an If you are setting the width and height like this: attrs: {
// ...
image: {
width: 'calc(w)', // this takes up all the available width
height: 'calc(h)', // this take up all the available height
},
// ...
} The problem arises when you resize the element and the width changes; the image will be preserving the aspect ratio in order not to distort the image. One way to handle this would be to add attrs: {
// ...
image: {
width: 'calc(w)', // this takes up all the available width
height: 'calc(h)', // this take up all the available height
preserveAspectRatio: 'none',
},
// ...
} For a simpler shape such as this one, I would instead recommend converting it to an SVG path which will behave more predictably, like so: const TrapezoidShape = joint.dia.Element.define('app.Trapezoid', {
attrs: {
body: {
d: 'M 0 0 L calc(w) calc(h/3) L calc(w) calc(2 * h/3) L 0 calc(h) Z',
stroke: '#333333',
fill: '#FFFFFF'
},
}
}, {
markup: [{
tagName: 'path',
selector: 'body'
}]
}); |
Beta Was this translation helpful? Give feedback.
-
As checked with given solution with |
Beta Was this translation helpful? Give feedback.
When a port group uses the default positioning algorithms, JointJS places the ports relative to the element’s bounding box - i.e., the rectangle defined by the element’s size attribute.
How exactly does your shape definition look like? Are you certain you need to be using an
image
? This shape could be declared as an SVG path using JointJS, which could potentially save you some work.If you are setting the width and height like this:
The problem arises when you resize the element an…