mirror of
https://github.com/projectstorm/react-diagrams.git
synced 2026-03-13 09:50:09 +08:00
Correct calculation when nodes are placed at the very edge of the canvas
This commit is contained in:
@@ -426,19 +426,22 @@ export class DiagramEngine extends BaseEntity<DiagramEngineListener> {
|
||||
Math.min(_.minBy(_.concat(allNodesCoords, allPortsCoords, allPointsCoords), item => item.x).x, 0) /
|
||||
ROUTING_SCALING_FACTOR
|
||||
) * ROUTING_SCALING_FACTOR;
|
||||
const maxX = Math.max(
|
||||
_.maxBy(_.concat(allNodesCoords, allPortsCoords, allPointsCoords), item => item.x + item.width).x,
|
||||
canvas.offsetWidth
|
||||
const maxXElement = _.maxBy(
|
||||
_.concat(allNodesCoords, allPortsCoords, allPointsCoords),
|
||||
item => item.x + item.width
|
||||
);
|
||||
const maxX = Math.max(maxXElement.x + maxXElement.width, canvas.offsetWidth);
|
||||
|
||||
const minY =
|
||||
Math.floor(
|
||||
Math.min(_.minBy(_.concat(allNodesCoords, allPortsCoords, allPointsCoords), item => item.y).y, 0) /
|
||||
ROUTING_SCALING_FACTOR
|
||||
) * ROUTING_SCALING_FACTOR;
|
||||
const maxY = Math.max(
|
||||
_.maxBy(_.concat(allNodesCoords, allPortsCoords, allPointsCoords), item => item.y + item.height).y,
|
||||
canvas.offsetHeight
|
||||
const maxYElement = _.maxBy(
|
||||
_.concat(allNodesCoords, allPortsCoords, allPointsCoords),
|
||||
item => item.y + item.height
|
||||
);
|
||||
const maxY = Math.max(maxYElement.y + maxYElement.height, canvas.offsetHeight);
|
||||
|
||||
return {
|
||||
width: Math.ceil(Math.abs(minX) + maxX),
|
||||
|
||||
@@ -306,15 +306,15 @@ export class DefaultLinkWidget extends React.Component<DefaultLinkProps, Default
|
||||
*/
|
||||
isSmartRoutingApplicable(): boolean {
|
||||
const { diagramEngine, link } = this.props;
|
||||
|
||||
|
||||
if (!diagramEngine.isSmartRoutingEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (link.points.length !== 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (link.sourcePort === null || link.targetPort === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user