Skip to content

@ue-too/board / index / restrictPanToHandler

関数: restrictPanToHandler()

restrictPanToHandler(destination, camera, config): Point

定義: packages/board/src/camera/camera-rig/pan-handler.ts:359

Handler pipeline step that applies axis restrictions to "pan to" destinations.

パラメータ

destination

Point

Target camera position in world space

camera

BoardCamera

Current camera instance

config

PanHandlerRestrictionConfig

Restriction configuration

戻り値

Point

Restricted destination position

Remarks

This handler enforces axis-lock constraints on absolute camera positioning. It converts the destination to a delta, applies restrictions, then converts back.

Algorithm:

  1. Calculate delta from current position to destination
  2. Apply restrictions using convertDeltaToComplyWithRestriction
  3. If delta becomes zero, return original destination (already at target)
  4. Otherwise, return current position + restricted delta

Can be used standalone, but typically composed into a handler pipeline via createDefaultPanToHandler or createHandlerChain.

typescript
// Standalone usage
const config: PanHandlerRestrictionConfig = {
  restrictYTranslation: true,  // Lock Y axis
  restrictXTranslation: false,
  restrictRelativeXTranslation: false,
  restrictRelativeYTranslation: false
};

const destination = { x: 1000, y: 500 };
const restricted = restrictPanToHandler(destination, camera, config);
// If camera is at { x: 0, y: 200 }, result is { x: 1000, y: 200 }

参照