Merge branch 'main' into fix-fit-view-origin

This commit is contained in:
peterkogo
2024-09-19 11:54:48 +02:00
3 changed files with 18 additions and 5 deletions
+8 -4
View File
@@ -20,7 +20,8 @@ import {
type ConnectionState,
type NodeOrigin,
getFitViewNodes,
updateAbsolutePositions
updateAbsolutePositions,
getDimensions
} from '@xyflow/system';
import type { EdgeTypes, NodeTypes, Node, Edge, FitViewOptions } from '$lib/types';
@@ -156,18 +157,21 @@ export function createStore({
function fitView(options?: FitViewOptions) {
const panZoom = get(store.panZoom);
const domNode = get(store.domNode);
if (!panZoom) {
if (!panZoom || !domNode) {
return Promise.resolve(false);
}
const { width, height } = getDimensions(domNode);
const fitViewNodes = getFitViewNodes(get(store.nodeLookup), options);
return fitViewSystem(
{
nodes: fitViewNodes,
width: get(store.width),
height: get(store.height),
width,
height,
minZoom: get(store.minZoom),
maxZoom: get(store.maxZoom),
panZoom