API: primitives (@fragiola/flow-react, @fragiola/flow-vue, @fragiola/flow-svelte, @fragiola/flow-angular)
FitView
Flow.FitView fits every node into the root with one press, and is disabled until the engine knows the size of a node.
Flow.FitView renders a button (type="button") that runs the engine's "fit-view" action:
it fits every node in the root, with a padding of 0.1, within the zoom limits. Before the root and a node have a size the engine refuses it, so the button is disabled (and data-disabled) while engine.can("fit-view") is false; it
re-renders when the view changes. It sets no text and no name: give it an icon and an
aria-label. Put it in Flow.Controls, or anywhere inside Flow.Root.
import { MaximizeIcon } from "lucide-react";
<Flow.FitView aria-label="Fit view" className="p-1 data-disabled:opacity-40">
<MaximizeIcon />
</Flow.FitView>;The same action from code: engine.run("fit-view") (engine). Its props are
the action's payload: one left out is not sent, so the engine's default applies. Pixels, per-side
padding and hidden nodes: What fit-view frames.
Props
FitViewProps extends the common primitive props and
every button attribute; a disabled of yours disables it too.
| prop | type | default | description |
|---|---|---|---|
duration | number | 0 | how long its viewport change animates, in milliseconds (the root's easing); 0: at once |
padding | FitPadding | 0.1 | the room kept free: a share of the root's size, "<n>px", or each side's { top, right, bottom, left } |
nodeIds | string[] | every node not hidden | only these nodes |
includeHidden | boolean | false | without nodeIds, the hidden nodes of known size too |
minZoom | number | the root's minZoom | the least zoom it may pick |
maxZoom | number | the root's maxZoom | the greatest zoom it may pick |
children | ReactNode | none | its icon or label |
State
ControlButtonState (Controls), what className, style and
render receive:
| field | type | description |
|---|---|---|
disabled | boolean | the engine refuses its action now, or its disabled prop is set |
Data attributes
| attribute | value |
|---|---|
data-flow-part | "fit-view" |
data-disabled | present while disabled |