Skip to content

@ue-too/board / index / PanByHandlerFunction

型エイリアス: PanByHandlerFunction()

PanByHandlerFunction = (delta, camera, config) => Point

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

Handler function type for relative "pan by" camera operations.

パラメータ

delta

Point

Movement delta in world space

camera

BoardCamera

Current camera instance

config

PanHandlerConfig

Pan behavior configuration

戻り値

Point

Transformed movement delta (after applying restrictions and clamping)

Remarks

Pan-by handlers process relative camera movement requests. They form a pipeline that can apply restrictions, clamping, and other transformations to the movement delta.

Handler pipeline pattern:

  • Each handler receives the current delta, camera state, and config
  • Returns a potentially modified delta
  • Handlers can be chained using createHandlerChain

Common transformations:

  • Axis restrictions (prevent movement on specific axes)
  • Boundary clamping (prevent moving outside bounds)
  • Delta dampening or acceleration

typescript
const myPanByHandler: PanByHandlerFunction = (delta, camera, config) => {
  // Custom logic: dampen large movements
  const magnitude = Math.sqrt(delta.x ** 2 + delta.y ** 2);
  if (magnitude > 100) {
    const scale = 100 / magnitude;
    return { x: delta.x * scale, y: delta.y * scale };
  }
  return delta;
};

参照