feat(svelte) add fitViewOptions, closes #3440

This commit is contained in:
Peter
2023-09-25 12:58:04 +02:00
parent 339df4c651
commit ada5b94673
9 changed files with 71 additions and 44 deletions
+1 -1
View File
@@ -160,7 +160,7 @@ export const getTransformForBounds = (
height: number,
minZoom: number,
maxZoom: number,
padding = 0.1
padding: number
): Transform => {
const xZoom = width / (bounds.width * (1 + padding));
const yZoom = height / (bounds.height * (1 + padding));
+4 -3
View File
@@ -180,10 +180,11 @@ export function fitView<Params extends FitViewParamsBase<NodeBase>, Options exte
return isVisible;
});
const nodesInitialized = filteredNodes.every((n) => n.width && n.height);
console.log(filteredNodes);
if (nodes.length > 0 && nodesInitialized) {
const bounds = getRectOfNodes(nodes, nodeOrigin);
if (filteredNodes.length > 0) {
const bounds = getRectOfNodes(filteredNodes, nodeOrigin);
console.log(bounds);
const [x, y, zoom] = getTransformForBounds(
bounds,