fix(minimap): sub flow node positions
This commit is contained in:
@@ -9,10 +9,11 @@
|
|||||||
import cc from 'classcat';
|
import cc from 'classcat';
|
||||||
import {
|
import {
|
||||||
getBoundsOfRects,
|
getBoundsOfRects,
|
||||||
|
getInternalNodesBounds,
|
||||||
getNodeDimensions,
|
getNodeDimensions,
|
||||||
getNodePositionWithOrigin,
|
getNodePositionWithOrigin,
|
||||||
getNodesBounds,
|
nodeHasDimensions,
|
||||||
nodeHasDimensions
|
type Rect
|
||||||
} from '@xyflow/system';
|
} from '@xyflow/system';
|
||||||
|
|
||||||
import { useStore } from '$lib/store';
|
import { useStore } from '$lib/store';
|
||||||
@@ -49,6 +50,7 @@
|
|||||||
const defaultHeight = 150;
|
const defaultHeight = 150;
|
||||||
const {
|
const {
|
||||||
nodes,
|
nodes,
|
||||||
|
nodeLookup,
|
||||||
viewport,
|
viewport,
|
||||||
width: containerWidth,
|
width: containerWidth,
|
||||||
height: containerHeight,
|
height: containerHeight,
|
||||||
@@ -71,7 +73,14 @@
|
|||||||
width: $containerWidth / $viewport.zoom,
|
width: $containerWidth / $viewport.zoom,
|
||||||
height: $containerHeight / $viewport.zoom
|
height: $containerHeight / $viewport.zoom
|
||||||
};
|
};
|
||||||
$: boundingRect = $nodes.length > 0 ? getBoundsOfRects(getNodesBounds($nodes), viewBB) : viewBB;
|
let boundingRect: Rect = viewBB;
|
||||||
|
|
||||||
|
$: {
|
||||||
|
boundingRect =
|
||||||
|
$nodeLookup.size > 0 ? getBoundsOfRects(getInternalNodesBounds($nodeLookup), viewBB) : viewBB;
|
||||||
|
$nodes;
|
||||||
|
}
|
||||||
|
|
||||||
$: elementWidth = width ?? defaultWidth;
|
$: elementWidth = width ?? defaultWidth;
|
||||||
$: elementHeight = height ?? defaultHeight;
|
$: elementHeight = height ?? defaultHeight;
|
||||||
$: scaledWidth = boundingRect.width / elementWidth;
|
$: scaledWidth = boundingRect.width / elementWidth;
|
||||||
@@ -122,8 +131,9 @@
|
|||||||
>
|
>
|
||||||
{#if ariaLabel}<title id={labelledBy}>{ariaLabel}</title>{/if}
|
{#if ariaLabel}<title id={labelledBy}>{ariaLabel}</title>{/if}
|
||||||
|
|
||||||
{#each $nodes as node (node.id)}
|
{#each $nodes as userNode (userNode.id)}
|
||||||
{#if nodeHasDimensions(node)}
|
{@const node = $nodeLookup.get(userNode.id)}
|
||||||
|
{#if node && nodeHasDimensions(node)}
|
||||||
{@const pos = getNodePositionWithOrigin(node).positionAbsolute}
|
{@const pos = getNodePositionWithOrigin(node).positionAbsolute}
|
||||||
{@const nodeDimesions = getNodeDimensions(node)}
|
{@const nodeDimesions = getNodeDimensions(node)}
|
||||||
<MinimapNode
|
<MinimapNode
|
||||||
|
|||||||
Reference in New Issue
Block a user