Skip to content

Extract zoom, pan, and touch gesture logic into a useZoomPan custom hook #133

Description

@Darkkal

Lightbox.tsx is currently ~1,479 lines long, with ~300 lines dedicated to managing zoom levels, pan offsets, drag start refs, pinch-to-zoom calculations, and boundary clamping (clampPanOffset).

Extracting this logic into a custom useZoomPan hook (e.g., src/hooks/useZoomPan.ts) will decouple stateful gesture/viewport calculations from layout and rendering, improving maintainability and enabling targeted testing.

Once extracted or exposed, unit tests should be added to verify edge clamping behavior (e.g., locking horizontal X axis in fitWidth, locking vertical Y axis in fitHeight, center boundary limits in zoom mode) to prevent regressions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorThis enhancement is related to a refactor

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions