chore(useReactFlow): cleanup fitView
This commit is contained in:
@@ -3,4 +3,4 @@
|
|||||||
'@xyflow/svelte': patch
|
'@xyflow/svelte': patch
|
||||||
---
|
---
|
||||||
|
|
||||||
Calculate viewport dimensions in fitView instead of using stored dimensions. Fixes [#4652](https://github.com/xyflow/xyflow/issues/4652)
|
Calculate viewport dimensions in `fitView` instead of using stored dimensions. Fixes [#4652](https://github.com/xyflow/xyflow/issues/4652)
|
||||||
|
|||||||
@@ -66,23 +66,25 @@ const useViewportHelper = (): ViewportHelperFunctions => {
|
|||||||
},
|
},
|
||||||
fitView: (options) => {
|
fitView: (options) => {
|
||||||
const { nodeLookup, minZoom, maxZoom, panZoom, domNode } = store.getState();
|
const { nodeLookup, minZoom, maxZoom, panZoom, domNode } = store.getState();
|
||||||
|
|
||||||
|
if (!panZoom || !domNode) {
|
||||||
|
return Promise.resolve(false);
|
||||||
|
}
|
||||||
|
|
||||||
const fitViewNodes = getFitViewNodes(nodeLookup, options);
|
const fitViewNodes = getFitViewNodes(nodeLookup, options);
|
||||||
|
const { width, height } = getDimensions(domNode);
|
||||||
|
|
||||||
const { width, height } = getDimensions(domNode!);
|
return fitView(
|
||||||
|
{
|
||||||
return panZoom
|
nodes: fitViewNodes,
|
||||||
? fitView(
|
width,
|
||||||
{
|
height,
|
||||||
nodes: fitViewNodes,
|
minZoom,
|
||||||
width,
|
maxZoom,
|
||||||
height,
|
panZoom,
|
||||||
minZoom,
|
},
|
||||||
maxZoom,
|
options
|
||||||
panZoom,
|
);
|
||||||
},
|
|
||||||
options
|
|
||||||
)
|
|
||||||
: Promise.resolve(false);
|
|
||||||
},
|
},
|
||||||
setCenter: async (x, y, options) => {
|
setCenter: async (x, y, options) => {
|
||||||
const { width, height, maxZoom, panZoom } = store.getState();
|
const { width, height, maxZoom, panZoom } = store.getState();
|
||||||
|
|||||||
Reference in New Issue
Block a user