Increase max auto zoom and add more constants

This commit is contained in:
Andrew Kingston 2024-09-12 16:09:37 +01:00
parent d80d38196f
commit d4451a487c
No known key found for this signature in database
3 changed files with 7 additions and 5 deletions

View File

@ -3,7 +3,7 @@
import { useSvelteFlow, Position } from "@xyflow/svelte" import { useSvelteFlow, Position } from "@xyflow/svelte"
import { getContext, tick } from "svelte" import { getContext, tick } from "svelte"
import { autoLayout, roleToNode } from "./layout" import { autoLayout, roleToNode } from "./layout"
import { ZoomDuration } from "./constants" import { MaxAutoZoom, ZoomDuration } from "./constants"
import { getSequentialName } from "helpers/duplicate" import { getSequentialName } from "helpers/duplicate"
import { roles } from "stores/builder" import { roles } from "stores/builder"
import { Roles } from "constants/backend" import { Roles } from "constants/backend"
@ -33,7 +33,7 @@
edges.set(layout.edges) edges.set(layout.edges)
await tick() await tick()
flow.fitView({ flow.fitView({
maxZoom: 1, maxZoom: MaxAutoZoom,
duration: ZoomDuration, duration: ZoomDuration,
}) })
} }
@ -54,7 +54,8 @@
</div> </div>
<Button <Button
secondary secondary
on:click={() => flow.fitView({ maxZoom: 1, duration: ZoomDuration })} on:click={() =>
flow.fitView({ maxZoom: MaxAutoZoom, duration: ZoomDuration })}
> >
Zoom to fit Zoom to fit
</Button> </Button>

View File

@ -10,7 +10,7 @@
FieldLabel, FieldLabel,
} from "@budibase/bbui" } from "@budibase/bbui"
import { Roles } from "constants/backend" import { Roles } from "constants/backend"
import { NodeWidth, NodeHeight } from "./constants" import { NodeWidth, NodeHeight, MaxAutoZoom, ZoomDuration } from "./constants"
import { getContext, tick } from "svelte" import { getContext, tick } from "svelte"
import { autoLayout, nodeToRole } from "./layout" import { autoLayout, nodeToRole } from "./layout"
import { roles } from "stores/builder" import { roles } from "stores/builder"
@ -79,7 +79,7 @@
const layout = autoLayout({ nodes: $nodes, edges: $edges }) const layout = autoLayout({ nodes: $nodes, edges: $edges })
nodes.set(layout.nodes) nodes.set(layout.nodes)
edges.set(layout.edges) edges.set(layout.edges)
flow.fitView({ maxZoom: 1, duration: 300 }) flow.fitView({ maxZoom: MaxAutoZoom, duration: ZoomDuration })
} }
</script> </script>

View File

@ -1,3 +1,4 @@
export const NodeWidth = 220 export const NodeWidth = 220
export const NodeHeight = 66 export const NodeHeight = 66
export const ZoomDuration = 300 export const ZoomDuration = 300
export const MaxAutoZoom = 1.2