Creates an instance of FitViewport and attaches it to a DiagramView. This allows the FitViewport to manipulate the viewport of the DiagramView when fitting content.
the DiagramView instance to attach to
Optionaloptions: { minZoom?: number; maxZoom?: number }optional configuration for minimum and maximum zoom levels
Adjusts the viewport to fit the width of the nodes within the visible area of the canvas.
Optionaloptions: { padding?: number; alignment?: FitAlign }Optional configuration for padding and alignment.
Adjusts the viewport to fit all nodes within the visible area of the canvas.
Optionaloptions: { padding?: number; alignment?: FitAlign }Optional configuration for padding and alignment.
ProtectedapplyApplies the calculated viewport settings (zoom and pan) to the diagram based on the provided bounds. This method applies a transform to the diagram's canvas and coordinate system.
Clamps the zoom value to the allowed range defined by minZoom and maxZoom.
The zoom value to clamp.
The clamped zoom value.
FitViewport is a utility class that provides methods to adjust the viewport of a DiagramView to fit its content (nodes) within the visible area. It calculates the appropriate zoom level and pan offset based on the dimensions of the nodes and the canvas, allowing for different alignment options (center, left, right, top, bottom). The class also includes methods to clamp the zoom level within specified minimum and maximum values.