Skip to content

@ue-too/board / index / restrictZoomToHandler

函式: restrictZoomToHandler() ​

restrictZoomToHandler(destination, camera, config): number

定義於: packages/board/src/camera/camera-rig/zoom-handler.ts:314

Handler pipeline step that prevents "zoom to" operations when zoom is locked.

參數 ​

destination ​

number

Target zoom level

camera ​

BoardCamera

Current camera instance

config ​

ZoomHandlerRestrictConfig

Restriction configuration

回傳 ​

number

Current zoom level (if locked) or destination (if unlocked)

備註 ​

This handler implements a global zoom lock for absolute zoom operations.

Behavior:

  • If restrictZoom is true: Returns current zoom level (prevents any change)
  • If restrictZoom is false: Returns destination unchanged

Use this for:

  • Disabling zoom during specific application states
  • Fixed-zoom viewing modes
  • Read-only camera modes

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

範例 ​

typescript
camera.zoomLevel = 2.0;

const config: ZoomHandlerRestrictConfig = {
  restrictZoom: true  // Lock zoom
};

const target = 3.0;
const result = restrictZoomToHandler(target, camera, config);
// result = 2.0 (zoom locked, returns current level)

參閱 ​

createDefaultZoomToOnlyHandler for default pipeline usage