feat(svelte): add fitViewOptions for Controls closes #4201

This commit is contained in:
moklick
2024-05-02 15:36:42 +02:00
parent 3b940ac5ae
commit f2f2c3cc2e
6 changed files with 18 additions and 9 deletions

View File

@@ -13,8 +13,8 @@
type Node,
type Edge,
ConnectionMode,
useSvelteFlow,
ControlButton
ControlButton,
type FitViewOptions
} from '@xyflow/svelte';
import CustomNode from './CustomNode.svelte';
@@ -33,6 +33,11 @@
custom: CustomEdge
};
const fitViewOptions: FitViewOptions = {
padding: 0.2,
nodes: [{ id: '1' }, { id: '2' }]
};
const nodes = writable<Node[]>([
{
id: '1',
@@ -191,7 +196,7 @@
attributionPosition={'top-center'}
deleteKey={['Backspace', 'd']}
>
<Controls orientation="horizontal">
<Controls orientation="horizontal" {fitViewOptions}>
<ControlButton slot="before">xy</ControlButton>
<ControlButton aria-label="log" on:click={() => console.log('control button')}
>log</ControlButton