From a3a9249d170f59f733b3e75479eec6a44afe65a9 Mon Sep 17 00:00:00 2001 From: moklick Date: Thu, 4 Nov 2021 14:14:11 +0100 Subject: [PATCH] fix(minimap): use abs pos --- src/additional-components/MiniMap/index.tsx | 46 +++++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/additional-components/MiniMap/index.tsx b/src/additional-components/MiniMap/index.tsx index 97443452..1f13149f 100644 --- a/src/additional-components/MiniMap/index.tsx +++ b/src/additional-components/MiniMap/index.tsx @@ -23,7 +23,13 @@ declare const window: any; const defaultWidth = 200; const defaultHeight = 150; -const selector = (s: ReactFlowState) => ({ width: s.width, height: s.height, transform: s.transform, nodes: s.nodes }); +const selector = (s: ReactFlowState) => ({ + width: s.width, + height: s.height, + transform: s.transform, + nodes: s.nodes, + nodeLookup: s.nodeLookup, +}); const MiniMap = ({ style, @@ -35,7 +41,7 @@ const MiniMap = ({ nodeStrokeWidth = 2, maskColor = 'rgb(240, 242, 243, 0.7)', }: MiniMapProps) => { - const { width: containerWidth, height: containerHeight, transform, nodes } = useStore(selector, shallow); + const { width: containerWidth, height: containerHeight, transform, nodes, nodeLookup } = useStore(selector, shallow); const [tX, tY, tScale] = transform; const mapClasses = cc(['react-flow__minimap', className]); @@ -77,22 +83,26 @@ const MiniMap = ({ > {nodes .filter((node) => !node.isHidden && node.width && node.height) - .map((node) => ( - - ))} + .map((node) => { + const positionAbsolute = nodeLookup.get(node.id)?.positionAbsolute; + + return ( + + ); + })}