Skip to main content

Class: PanZoomControls

Defined in: src/interaction/PanZoomControls.ts:108

Desmos-style pan and zoom for a 2D (orthographic) manim camera, with mouse and touch input.

Wheel zooms the frame about the world point under the cursor (zoom to cursor, not to center); a mouse drag pans the frame. On touch devices, a one-finger drag pans, and a two-finger gesture pinch-zooms about the midpoint of the two touches while panning by the midpoint delta. The controller only reads/writes the camera through PanZoomCamera; it never touches the core render path, so it is a pure opt-in input controller.

Lifecycle mirrors OrbitControls: listeners are attached while the controller is enabled and removed on disable() / dispose().

Example​

const controls = new PanZoomControls(scene.camera, scene.getCanvas(), {
onChange: () => scene.render(),
});
// later
controls.dispose();

Constructors​

Constructor​

new PanZoomControls(camera, domElement, options?): PanZoomControls

Defined in: src/interaction/PanZoomControls.ts:138

Parameters​

camera​

PanZoomCamera

The 2D camera to drive (e.g. scene.camera).

domElement​

HTMLElement

The element that receives wheel/mouse/touch events (e.g. the canvas).

options?​

PanZoomControlsOptions

Pan/zoom configuration.

Returns​

PanZoomControls

Methods​

disable()​

disable(): void

Defined in: src/interaction/PanZoomControls.ts:200

Detach listeners. The controller stops responding until enable() is called.

Returns​

void


dispose()​

dispose(): void

Defined in: src/interaction/PanZoomControls.ts:220

Permanently detach listeners. The controller cannot be re-enabled.

Returns​

void


enable()​

enable(): void

Defined in: src/interaction/PanZoomControls.ts:181

Attach listeners and start responding to the mouse.

Returns​

void


isEnabled()​

isEnabled(): boolean

Defined in: src/interaction/PanZoomControls.ts:176

Whether the controller is currently enabled (listeners attached).

Returns​

boolean