20 lines
798 B
TypeScript
20 lines
798 B
TypeScript
/**
|
|
* Pan/zoom geometry for the Stammbaum canvas (#692).
|
|
*
|
|
* The Stammbaum renders zoom by deriving the SVG `viewBox` rather than applying
|
|
* a CSS transform (see `StammbaumTree.svelte`). This module is the single source
|
|
* of truth for the zoom bounds, the view-state shape, and every pure geometry
|
|
* helper used by the gesture action, the URL serialiser, and the page. Keeping
|
|
* the math here (and free of DOM access) makes it unit-testable in the node
|
|
* project. See ADR-026 for why this is custom rather than a third-party library.
|
|
*/
|
|
|
|
/** Resolved zoom bounds (OQ-001). */
|
|
export const MIN_ZOOM = 0.25;
|
|
export const MAX_ZOOM = 3.0;
|
|
|
|
/** Clamp a zoom factor into the supported range. */
|
|
export function clampZoom(z: number): number {
|
|
return Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, z));
|
|
}
|