Class pv.Behavior.pan
Extends
pv.Behavior.
Implements interactive panning starting with mousedown events.
Register this behavior on panels to allow panning. This behavior can be used
in tandem with pv.Behavior.zoom to allow both panning and zooming:
.event("mousedown", pv.Behavior.pan()) .event("mousewheel", pv.Behavior.zoom())The pan behavior currently supports only mouse events; support for keyboard shortcuts to improve accessibility may be added in the future.
After the initial mousedown event is triggered, this behavior listens for mousemove and mouseup events on the window. This allows panning to continue even if the mouse temporarily leaves the panel that is being panned, or even the root panel.
The implementation of this behavior relies on the panel's transform property, which specifies a matrix transformation that is applied to child marks. Note that the transform property only affects the panel's children, but not the panel itself; therefore the panel's fill and stroke will not change when the contents are panned.
Panels have transparent fill styles by default; this means that panels may not receive the initial mousedown event to start panning. To fix this problem, either given the panel a visible fill style (such as "white"), or set the events property to "all" such that the panel receives events despite its transparent fill.
The pan behavior has optional support for bounding. If enabled, the user
will not be able to pan the panel outside of the initial bounds. This feature
is designed to work in conjunction with the zoom behavior; otherwise,
bounding the panel effectively disables all panning.
Defined in: Pan.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Returns a new pan behavior to be registered on mousedown events.
|
Method Attributes | Method Name and Description |
---|---|
bound(x)
Sets or gets the bound parameter.
|
Note: enabling bounding after panning has already occurred will not immediately reset the transform. Bounding should be enabled before the panning behavior is applied.
- Parameters:
- {boolean} x Optional
- the new bound parameter.
- Returns:
- {pv.Behavior.pan} this, or the current bound parameter.