Used by CanvasComponent to limit the interactive movement of the viewport.
Remarks
Type Details
- yFiles module
- view
See Also
Constructors
Initializes a new instance of the ViewportLimiter class.
Parameters
A map of options to pass to the method.
- useContentBounds - boolean
- A value that determines whether the CanvasComponent's contentBounds should be implicitly used as the bounds to limit against. This option sets the useContentBounds property on the created object.
- strictBoundsContainment - boolean
- A value that describes how bounds should be treated. This option sets the strictBoundsContainment property on the created object.
- policy - ViewportLimitingPolicy
- The policy on how the viewport is limited if the current viewport is not within the limits. This option sets the policy property on the created object.
- bounds - Rect
- The maximal allowed navigable bounds for the viewport. This option sets the bounds property on the created object.
- viewportContentMargins - Insets
- The margins in the view coordinate system around the tight bounds in world coordinates. This option sets the viewportContentMargins property on the created object.
- minimumViewportContentRatio - Size
- The percentage of the width and height of the viewport that should be reserved *at least* when viewportContentMargins are defined. This option sets the minimumViewportContentRatio property on the created object.
Properties
Gets or sets the maximal allowed navigable bounds for the viewport.
Property Value
null
. This value will be used by the default implementation of limitViewport to crop the desired viewport to.Gets or sets the percentage of the width and height of the viewport that should be reserved *at least* when viewportContentMargins are defined.
Remarks
0.8
for both dimensions, so 80% of the space is reserved for the contents and margins can take up at most 10% of the space on each side. In these cases this space is distributed such that it corresponds to the ratio of the left/right and/or top/bottom viewportContentMargins.Gets or sets the policy on how the viewport is limited if the current viewport is not within the limits.
Remarks
Gets or sets a value that describes how bounds should be treated.
Remarks
If set to true
the viewport is limited in a way that the viewport must only show elements inside the bounds and no area outside the bounds should ever be visible. If the aspect ratio of the viewport and bounds differ, parts of the viewport will always be cropped as zooming out will be restricted by one axis. In video terminology, this setting is often referred to as "crop" or "cropping". When combined with projection, this feature will effectively prevent the user from reaching all parts within bounds without zooming in very far because the space around the "tips" of the bounds in the viewport are not aligned with the viewport.
If set to false
the viewport is only limited in a way that while it is possible to see parts outside the bounds, the process tries to minimize the amount of possible space outside the bounds. If the aspect ratio of the viewport and bounds differ, parts of the viewport will be outside the limits. In video terminology, this setting is often referred to as "letterbox" or "letterboxing". In other words, with this option, it will be possible to zoom out so that all bounds can be visible at the same time. When combined with projection, this feature will allow the user to fully see elements that lie at the border of bounds without zooming in very far because the viewport is allowed to go beyond the bounds, but only so far as not more whitespace will become visible than necessary to show more of the inside of the bounds.
Default is false
.
Property Value
Gets or sets a value that determines whether the CanvasComponent's contentBounds should be implicitly used as the bounds to limit against.
Remarks
true
the contentBounds will be used as the bounds if none are specified, otherwise. getCurrentBoundingPolygon will obtain the bounds from the control if bounds is still unspecified (null
). By default, this feature is enabled.See Also
Gets or sets the margins in the view coordinate system around the tight bounds in world coordinates.
Remarks
20.0
margins on all sides. If the horizontal or vertical margins exceed the space given by the minimumViewportContentRatio the available space is distributed such that it corresponds to the ratio of the left/right and/or top/bottom viewportContentMargins.Methods
getCurrentBoundingPolygon
(canvasComponent: CanvasComponent, requestedViewport: ViewportDescriptor, mode: ViewportLimitingMode) : PointGets the bounding polygon that should be honored for the upcoming limiting call.
Remarks
Parameters
A map of options to pass to the method.
- canvasComponent - CanvasComponent
- The canvas control.
- requestedViewport - ViewportDescriptor
- The requested new viewport.
- mode - ViewportLimitingMode
- The current limiting mode for the request.
Returns
- ↪Point[]?
- The bounds in the world coordinate system in the form of a strictly convex polygon where the points are given in clockwise order.
null
if there are no restrictions.
limitViewport
(canvasComponent: CanvasComponent, requestedViewport: ViewportDescriptor, mode: ViewportLimitingMode) : ViewportDescriptorInspects the requested new viewport for the given CanvasComponent and returns a valid viewport to use.
Parameters
A map of options to pass to the method.
- canvasComponent - CanvasComponent
- The canvas on which the viewport should be applied.
- requestedViewport - ViewportDescriptor
- The viewport as requested by the caller.
- mode - ViewportLimitingMode
- A context that describes the current request. Specifically, this controls whether the current viewport should be honored and/or whether this change is an incremental, interactive, or programmatically triggered change. This is used for example by fitContent or ZOOM_TO_CURRENT_ITEM where larger viewport changes are expected, whereas interactive drags and scrollbar movements can be handled more gracefully depending on context.
Returns
- ↪ViewportDescriptor
- A valid viewport that should be used.