Skip to content

PanZoomControls ​

Camera controls for 2D pan and zoom with an orthographic camera.

Dragging with the left mouse button pans the view and the scroll wheel zooms around the cursor, keeping the point under the pointer fixed. Movement applies immediately with no inertia or damping.

ts
const camera = new OrthographicCamera({
  left: 0,
  right: 1024,
  top: 0,
  bottom: 1024,
});

const idetik = new Idetik({
  canvas,
  viewports: [{
    camera,
    layers: [imageLayer],
    cameraControls: new PanZoomControls(camera),
  }],
});

Implements CameraControls.

Constructor ​

Creates pan and zoom controls for the given camera.

ts
new PanZoomControls(camera, params?): PanZoomControls;
ParameterDescription
camera: OrthographicCameraThe orthographic camera to control.
params?: PanZoomControlsPropsInitialization properties.

Types ​

PanZoomControlsProps ​

Initialization properties for constructing pan and zoom controls.

PropertyDescription
scrollZoom?: ScrollZoomModeWhen the scroll wheel zooms. Defaults to "always".

Accessors ​

isMoving boolean ​

Whether a pan drag is in progress.

ts
get isMoving(): boolean;

Methods ​

onEvent() void ​

Handles a pointer or wheel event. Called automatically by the owning viewport unless a layer stops propagation.

ts
onEvent(event): void;
ParameterDescription
event: EventContextThe event with clip and world coordinates attached.

onUpdate() void ​

Does nothing. Pan and zoom apply immediately with no inertia.

ts
onUpdate(_delta): void;
ParameterDescription
_delta: numberTime since the last frame in seconds. Unused.

Released under the MIT License