documentationfor yFiles for HTML 2.6

Zooming, Panning, and Scrolling

Canvas navigation can be divided into two main categories: zooming and scrollbar handling which is managed by the CanvasComponent itself, and panning which is managed by the MoveViewportInputMode.

The scrollable area as well as the zoom can be efficiently limited using a ViewportLimiter as discussed in the section Restricting the Viewport.

Mouse Wheel and Scroll Bars

The GraphComponent provides a number of properties which allow specifying mouse wheel behavior, scroll bar policy, and zoom limits.

mouseWheelBehavior
Whether the mouse wheel is used to zoom or scroll (or both).
mouseWheelZoomFactor
How fast the zoom level changes when the mouse wheel is turned.
mouseWheelScrollFactor
How fast the viewport scrolls when the mouse wheel is turned.
centerZoomEventRecognizer
An event recognizer which determines whether zooming is towards the center of the view or towards the mouse location.
mouseWheelZoomEventRecognizer
An event recognizer which determines whether mouse wheel turns should scroll or zoom. This recognizer is only used if mouseWheelBehavior has both the SCROLL and ZOOM flags.
verticalScrollBarPolicy
horizontalScrollBarPolicy
Whether and when to display vertical and horizontal scroll bars.
minimumZoom
maximumZoom
Minimum and maximum allowed values for the zoom factor.

Related events
Event Occurs when …​
ViewportChanged…​ the viewport has been changed. This also happens when the zoom factor changes, or the scrollbars change visibility.
ZoomChanged…​ the zoom factor has been changed.

Panning

Panning, i.e. dragging the visible area with the mouse, is handled by MoveViewportInputMode. This input mode is a child input mode of both GraphEditorInputMode and GraphViewerInputMode.

MoveViewportInputMode allows customization by changing the recognizers for some gestures. This might be of importance to avoid conflicts with input modes which share the same gesture (dragging on an empty canvas), e.g. MarqueeSelectionInputMode or LassoSelectionInputMode.

pressedRecognizer
An event recognizer which returns true if an event is recognized as a valid gesture during viewport movement. This recognizer has to return true for all events during the complete drag gesture.
draggedRecognizer
An event recognizer which returns true if an event is recognized as a drag gesture that actually starts moving the viewport. This is only queried if the pressedRecognizer already returns true.
releasedRecognizer
An event recognizer which returns true if an event is recognized as a valid gesture to finish panning.

MoveViewportInputMode also supports touch gestures. Besides panning its touch support also manages zooming by pinch gestures.

primaryDownRecognizer
An event recognizer which returns true if an event is recognized as a gesture that can start a marquee selection or a pinch zoom, usually the primary touch (i.e. "first finger down").
primaryMoveRecognizer
An event recognizer which returns true if an event is recognized as a drag gesture. The gesture actually starts moving the viewport if no secondary touch device is down, otherwise it starts a pinch zoom gesture. This is only queried if the primaryMoveRecognizer already returns true.
primaryUpRecognizer
An event recognizer which returns true if an event is recognized as a valid gesture to finish panning.
secondaryDownRecognizer
An event recognizer which returns true if an event is recognized as a valid gesture to start the actual pinch zoom, usually the second touch ("second finger down"). secondaryMoveRecognizerAn event recognizer which returns true if an event is recognized as a pinch gesture (if primary touch device is down) or pan (if no primary touch device is down).
secondaryUpRecognizer
An event recognizer which returns true if an event is recognized as a valid gesture to finish pinch zoom or panning if no primary touch is down.

Related events
Event Occurs when …​
DragStarting…​ a drag gesture is recognized, but before the input mode is initialized for dragging.
DragStarted…​ a drag gesture is recognized, after the input mode has been initialized for dragging.
Dragging…​ the mouse is moved during drag operations and before the viewport is moved in response to that drag.
Dragged…​ the mouse is moved during drag operations and after the viewport has been moved in response to that drag.
DragCanceling…​ a drag gesture is canceled, but before the input mode has been cleaned up.
DragCanceled…​ a drag gesture is canceled, after the input mode has been cleaned up.
DragFinishing…​ a drag gesture has ended successfully, but before any final cleanup happens.
DragFinished…​ a drag gesture has ended successfully, after final cleanup has happened.