Documentation / @ripl/dom / DOMNavigator
Class: DOMNavigator ​
Defined in: dom/src/navigator.ts:61
DOM-bound Navigator that translates real wheel/pointer/touch gestures into the base navigator's imperative commands: the pan/zoom/brush analogue of how DOMContext adds real event listeners on top of the abstract Context. The base class in @ripl/core owns the view model and stays context-agnostic; this subclass owns input.
The gesture model is intentionally Figma-like so a navigator can roam a scene freely:
- click-and-hold drag (left or middle button, with or without ⌘/Ctrl) pans the view;
- wheel zooms toward the pointer, and a two-finger pinch zooms toward the gesture center;
- ⇧ shift-drag brushes a rectangular selection when brushing is enabled.
Because the base transform is unbounded, dragging past the viewport edge (the pointer is captured for the duration of the drag) keeps panning, so content outside the current viewport can be reached and then re-framed with the base centerOn/fitBounds helpers.
Extends ​
Constructors ​
Constructor ​
new DOMNavigator(
context,options?):DOMNavigator
Defined in: dom/src/navigator.ts:77
Parameters ​
| Parameter | Type |
|---|---|
context | Context |
options? | DOMNavigatorOptions |
Returns ​
DOMNavigator
Overrides ​
Properties ​
| Property | Modifier | Type | Default value | Description | Inherited from | Defined in |
|---|---|---|---|---|---|---|
_brush | protected | NavigatorBrush | null | null | - | Navigator._brush | core/src/core/navigator.ts:177 |
_scaleExtent | protected | [number, number] | undefined | - | Navigator._scaleExtent | core/src/core/navigator.ts:178 |
_transform | protected | NavigatorTransform | undefined | - | Navigator._transform | core/src/core/navigator.ts:180 |
_viewport | protected | NavigatorViewport | undefined | - | Navigator._viewport | core/src/core/navigator.ts:179 |
parent? | public | EventBus<NavigatorEventMap> | undefined | The parent event bus that emitted events bubble up to, if any. | Navigator.parent | core/src/core/event-bus.ts:107 |
defaultKey | readonly | typeof defaultKey | undefined | The key under which resources are retained when no explicit key is provided. | Navigator.defaultKey | core/src/core/disposer.ts:11 |
Accessors ​
$events ​
Get Signature ​
get $events(): keyof
NavigatorEventMap[]
Defined in: core/src/core/navigator.ts:187
The event types a navigator can emit. See EventBus.$events.
Returns ​
keyof NavigatorEventMap[]
Inherited from ​
brush ​
Get Signature ​
get brush():
NavigatorBrush|null
Defined in: core/src/core/navigator.ts:206
The current brush selection, or null when nothing is selected.
Returns ​
NavigatorBrush | null
Inherited from ​
scaleExtent ​
Get Signature ​
get scaleExtent(): [
number,number]
Defined in: core/src/core/navigator.ts:213
The minimum/maximum zoom factor the transform is clamped to.
Returns ​
[number, number]
Inherited from ​
transform ​
Get Signature ​
get transform():
NavigatorTransform
Defined in: core/src/core/navigator.ts:199
The current view transform (a copy; mutating it does not affect the navigator).
Returns ​
Inherited from ​
viewport ​
Get Signature ​
get viewport():
NavigatorViewport
Defined in: core/src/core/navigator.ts:220
The viewport dimensions used by centerOn/fitBounds.
Returns ​
Set Signature ​
set viewport(
viewport):void
Defined in: core/src/core/navigator.ts:226
Parameters ​
| Parameter | Type |
|---|---|
viewport | NavigatorViewport |
Returns ​
void
Inherited from ​
Methods ​
_commit() ​
protected_commit(event):void
Defined in: core/src/core/navigator.ts:242
Parameters ​
| Parameter | Type |
|---|---|
event | "zoom" | "pan" |
Returns ​
void
Inherited from ​
applyPoint() ​
applyPoint(
point):Point
Defined in: core/src/core/navigator.ts:250
Applies the transform to a point in content space, returning its on-screen position in logical pixels.
Parameters ​
| Parameter | Type |
|---|---|
point | Point |
Returns ​
Inherited from ​
centerOn() ​
centerOn(
point,viewport?):void
Defined in: core/src/core/navigator.ts:321
Centers a content-space point within the viewport, keeping the current zoom. Useful for bringing an off-screen element into view without changing scale.
Parameters ​
| Parameter | Type |
|---|---|
point | Point |
viewport | NavigatorViewport |
Returns ​
void
Inherited from ​
clearBrush() ​
clearBrush():
void
Defined in: core/src/core/navigator.ts:389
Clears the brush selection and emits a brushend event with null.
Returns ​
void
Inherited from ​
destroy() ​
destroy():
void
Defined in: dom/src/navigator.ts:320
Detaches all interaction listeners and disposes the navigator.
Returns ​
void
Overrides ​
dispose() ​
protecteddispose(key?):void
Defined in: core/src/core/disposer.ts:25
Disposes all resources under the given key, or all resources if no key is provided.
Parameters ​
| Parameter | Type |
|---|---|
key? | PropertyKey |
Returns ​
void
Inherited from ​
emit() ​
Call Signature ​
emit<
TEvent>(event):TEvent
Defined in: core/src/core/event-bus.ts:185
Emits an event, invoking all matching handlers and bubbling to the parent if applicable. Handlers for the event's own type run first, then EVENT_WILDCARD subscriptions.
Type Parameters ​
| Type Parameter | Default type |
|---|---|
TEvent extends Event<undefined> | Event<undefined> |
Parameters ​
| Parameter | Type |
|---|---|
event | TEvent |
Returns ​
TEvent
Inherited from ​
Call Signature ​
emit<
TEvent>(type,data):Event<NavigatorEventMap[TEvent]>
Defined in: core/src/core/event-bus.ts:186
Emits an event, invoking all matching handlers and bubbling to the parent if applicable. Handlers for the event's own type run first, then EVENT_WILDCARD subscriptions.
Type Parameters ​
| Type Parameter |
|---|
TEvent extends keyof NavigatorEventMap |
Parameters ​
| Parameter | Type |
|---|---|
type | TEvent |
data | NavigatorEventMap[TEvent] |
Returns ​
Event<NavigatorEventMap[TEvent]>
Inherited from ​
fitBounds() ​
fitBounds(
bounds,options?):void
Defined in: core/src/core/navigator.ts:338
Zooms and pans so a content-space box fills the viewport (respecting the scale extent and an optional padding). This is the primary way to jump the view to content, including content that currently lies entirely outside the viewport.
Parameters ​
| Parameter | Type |
|---|---|
bounds | NavigatorBrush |
options? | NavigatorFitOptions |
Returns ​
void
Inherited from ​
has() ​
has(
type):boolean
Defined in: core/src/core/event-bus.ts:123
Returns whether there are any listeners registered for the given event type. Wildcard subscriptions (EVENT_WILDCARD) are not listeners for any concrete type, so a bus observed only through the wildcard still reports false here.
Parameters ​
| Parameter | Type |
|---|---|
type | keyof NavigatorEventMap |
Returns ​
boolean
Inherited from ​
invertPoint() ​
invertPoint(
point):Point
Defined in: core/src/core/navigator.ts:258
Inverts an on-screen point, in logical pixels, back to content space.
Parameters ​
| Parameter | Type |
|---|---|
point | Point |
Returns ​
Inherited from ​
off() ​
off<
TEvent>(type,handler):void
Defined in: core/src/core/event-bus.ts:144
Removes a previously registered handler for the given event type.
Type Parameters ​
| Type Parameter |
|---|
TEvent extends keyof NavigatorEventMap |
Parameters ​
| Parameter | Type |
|---|---|
type | TEvent |
handler | EventHandler<NavigatorEventMap[TEvent]> |
Returns ​
void
Inherited from ​
on() ​
on<
TEvent>(type,handler,options?):Disposable
Defined in: core/src/core/event-bus.ts:131
Subscribes a handler to the given event type and returns a disposable for cleanup. Pass EVENT_WILDCARD to receive every event emitted on the bus regardless of type.
Type Parameters ​
| Type Parameter |
|---|
TEvent extends keyof NavigatorEventMap |
Parameters ​
| Parameter | Type |
|---|---|
type | TEvent |
handler | EventHandler<NavigatorEventMap[TEvent]> |
options? | EventSubscriptionOptions |
Returns ​
Inherited from ​
once() ​
once<
TEvent>(type,handler,options?):Disposable
Defined in: core/src/core/event-bus.ts:159
Subscribes a handler that is automatically removed after it fires once.
Type Parameters ​
| Type Parameter |
|---|
TEvent extends keyof NavigatorEventMap |
Parameters ​
| Parameter | Type |
|---|---|
type | TEvent |
handler | EventHandler<NavigatorEventMap[TEvent]> |
options? | EventSubscriptionOptions |
Returns ​
Inherited from ​
panBy() ​
panBy(
dx,dy):void
Defined in: core/src/core/navigator.ts:277
Pans the view by a pixel delta.
Parameters ​
| Parameter | Type |
|---|---|
dx | number |
dy | number |
Returns ​
void
Inherited from ​
panTo() ​
panTo(
x,y):void
Defined in: core/src/core/navigator.ts:288
Pans the view to an absolute translation.
Parameters ​
| Parameter | Type |
|---|---|
x | number |
y | number |
Returns ​
void
Inherited from ​
reset() ​
reset():
void
Defined in: core/src/core/navigator.ts:366
Resets the transform to the identity (no zoom, no pan).
Returns ​
void
Inherited from ​
retain() ​
protectedretain(value,key?):void
Defined in: core/src/core/disposer.ts:14
Registers a disposable resource under an optional key for later cleanup.
Parameters ​
| Parameter | Type | Default value |
|---|---|---|
value | Disposable | undefined |
key | PropertyKey | Disposer.defaultKey |
Returns ​
void
Inherited from ​
setBrush() ​
setBrush(
brush):void
Defined in: core/src/core/navigator.ts:377
Sets the brush selection, normalizing the extent, and emits a brush event.
Parameters ​
| Parameter | Type |
|---|---|
brush | NavigatorBrush |
Returns ​
void
Inherited from ​
setTransform() ​
setTransform(
transform):void
Defined in: core/src/core/navigator.ts:266
Replaces the view transform outright (clamping k to the scale extent).
Parameters ​
| Parameter | Type |
|---|---|
transform | NavigatorTransform |
Returns ​
void
Inherited from ​
zoomBy() ​
zoomBy(
factor,center?):void
Defined in: core/src/core/navigator.ts:299
Multiplies the zoom by factor, keeping center (logical pixels, defaults to the origin) fixed.
Parameters ​
| Parameter | Type |
|---|---|
factor | number |
center | Point |
Returns ​
void
Inherited from ​
zoomTo() ​
zoomTo(
k,center?):void
Defined in: core/src/core/navigator.ts:313
Sets the absolute zoom factor, keeping center fixed.
Parameters ​
| Parameter | Type |
|---|---|
k | number |
center | Point |
Returns ​
void