mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-10 02:49:40 +02:00
Merge pull request #13 from Mermaid-Chart/fix-node-resize-intersection
fix intersection required object read from db while resizing node
This commit is contained in:
@@ -118,20 +118,21 @@ If the start node doesn't exist in the nodeDB (e.g. `render` hasn't been called
|
||||
|
||||
#### Defined in
|
||||
|
||||
[packages/mermaid/src/rendering-util/layout-algorithms/fixed/index.js:106](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/layout-algorithms/fixed/index.js#L106)
|
||||
[packages/mermaid/src/rendering-util/layout-algorithms/fixed/index.js:115](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/layout-algorithms/fixed/index.js#L115)
|
||||
|
||||
---
|
||||
|
||||
### calcNodeIntersections
|
||||
|
||||
▸ **calcNodeIntersections**(`_node1`, `_node2`): `IntersectionPoint`\[] | `Promise`<`IntersectionPoint`\[]>
|
||||
▸ **calcNodeIntersections**(`targetNodeId`, `_node1`, `_node2`): `IntersectionPoint`\[] | `Promise`<`IntersectionPoint`\[]>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------- | :------------------------------------------------------------------------------------------------ |
|
||||
| `_node1` | `Pick`<`Node`, `"width"` \| `"height"` \| `"x"` \| `"y"` \| `"id"` \| `"shape"` \| `"intersect"`> |
|
||||
| `_node2` | `Pick`<`Node`, `"width"` \| `"height"` \| `"x"` \| `"y"` \| `"id"` \| `"shape"` \| `"intersect"`> |
|
||||
| Name | Type |
|
||||
| :------------- | :------------------------------------------------------------------------------------------------ |
|
||||
| `targetNodeId` | `any` |
|
||||
| `_node1` | `Pick`<`Node`, `"width"` \| `"height"` \| `"x"` \| `"y"` \| `"id"` \| `"shape"` \| `"intersect"`> |
|
||||
| `_node2` | `Pick`<`Node`, `"width"` \| `"height"` \| `"x"` \| `"y"` \| `"id"` \| `"shape"` \| `"intersect"`> |
|
||||
|
||||
#### Returns
|
||||
|
||||
|
@@ -75,14 +75,23 @@ const calcIntersectionPoint = (node, point) => {
|
||||
* @param {Pick<Node, 'shape' | 'id' | 'intersect' | 'x' | 'y' | 'width' | 'height'>} _node2
|
||||
* @returns {Promise<IntersectionPoint[]> | IntersectionPoint[]}
|
||||
*/
|
||||
export const calcNodeIntersections = async (_node1, _node2) => {
|
||||
export const calcNodeIntersections = async (targetNodeId, _node1, _node2) => {
|
||||
// CReate new nodes in order not to require a rendered diagram
|
||||
const fakeParent = document.createElementNS('http://www.w3.org/2000/svg', 'g');
|
||||
const parent = select(fakeParent);
|
||||
const node1 = Object.assign({}, _node1);
|
||||
const node2 = Object.assign({}, _node2);
|
||||
await insertNode(parent, node1, 'TB');
|
||||
await insertNode(parent, node2, 'TB');
|
||||
let node1 = Object.assign({}, _node1);
|
||||
let node2 = Object.assign({}, _node2);
|
||||
|
||||
if (!targetNodeId || targetNodeId === _node1.id) {
|
||||
await insertNode(parent, node1, 'TB');
|
||||
} else {
|
||||
node1 = Object.assign({}, nodeDB.get(_node1.id));
|
||||
}
|
||||
if (!targetNodeId || targetNodeId === _node2.id) {
|
||||
await insertNode(parent, node2, 'TB');
|
||||
} else {
|
||||
node2 = Object.assign({}, nodeDB.get(_node2.id));
|
||||
}
|
||||
|
||||
// Insert node will not give any widths as the element is not in the DOM
|
||||
node1.width = _node1.width || 50;
|
||||
|
Reference in New Issue
Block a user