@ue-too/board / clampToHandler
Function: clampToHandler()
clampToHandler(
destination,camera,config):Point
Defined in: packages/board/src/camera/camera-rig/pan-handler.ts:467
Handler pipeline step that clamps "pan to" destinations to camera boundaries.
Parameters
destination
Point
Target camera position in world space
camera
Current camera instance (provides boundaries and viewport dimensions)
config
Clamping configuration
Returns
Point
Clamped destination position
Remarks
This handler enforces boundary constraints on absolute camera positioning. Behavior depends on configuration:
- If
clampTranslationis false: Returns destination unchanged (no clamping) - If
limitEntireViewPortis false: Clamps camera center to boundaries - If
limitEntireViewPortis true: Ensures entire viewport rectangle stays in bounds
The entire-viewport mode accounts for:
- Viewport dimensions (width/height)
- Current zoom level (affects viewport size in world space)
- Camera rotation (affects viewport orientation)
Can be used standalone, but typically composed into a handler pipeline via createDefaultPanToHandler or createHandlerChain.
Example
typescript
// Standalone usage - ensure entire viewport stays in bounds
camera.boundaries = {
min: { x: 0, y: 0 },
max: { x: 2000, y: 1000 }
};
const config: PanHandlerClampConfig = {
clampTranslation: true,
limitEntireViewPort: true
};
const destination = { x: 2500, y: 500 }; // Outside bounds
const clamped = clampToHandler(destination, camera, config);
// Result keeps entire viewport within [0,0] to [2000,1000]See
- clampPoint for center-point clamping
- clampPointEntireViewPort for full-viewport clamping
- createDefaultPanToHandler for default pipeline usage