fix(react,svelte): calculate viewport dimensions inside of fitView action

This commit is contained in:
braks
2024-09-18 14:24:40 +02:00
parent ce51e02acf
commit f70c5bb68f
2 changed files with 12 additions and 5 deletions
@@ -6,6 +6,7 @@ import {
fitView,
type XYPosition,
rendererPointToPoint,
getDimensions,
} from '@xyflow/system';
import { useStoreApi } from '../hooks/useStore';
@@ -64,9 +65,11 @@ const useViewportHelper = (): ViewportHelperFunctions => {
return { x, y, zoom };
},
fitView: (options) => {
const { nodeLookup, width, height, minZoom, maxZoom, panZoom } = store.getState();
const { nodeLookup, minZoom, maxZoom, panZoom, domNode } = store.getState();
const fitViewNodes = getFitViewNodes(nodeLookup, options);
const { width, height } = getDimensions(domNode!);
return panZoom
? fitView(
{