diff --git a/src/core/interaction/clip-interaction.ts b/src/core/interaction/clip-interaction.ts index c196fc83..193fde5b 100644 --- a/src/core/interaction/clip-interaction.ts +++ b/src/core/interaction/clip-interaction.ts @@ -15,8 +15,10 @@ import type { Size, Vector } from "@layouts/geometry"; export const INTERACTION_CONSTANTS = { /** Minimum clip dimension in pixels */ MIN_DIMENSION: 50, - /** Maximum clip dimension in pixels */ - MAX_DIMENSION: 3840 + /** Maximum clip width in pixels */ + MAX_WIDTH: 3840, + /** Maximum clip height in pixels */ + MAX_HEIGHT: 2160 } as const; // ─── Types ──────────────────────────────────────────────────────────────────── @@ -222,8 +224,8 @@ export function calculateEdgeResize(direction: EdgeDirection, delta: Vector, ori */ export function clampDimensions(width: number, height: number): { width: number; height: number } { return { - width: Math.max(INTERACTION_CONSTANTS.MIN_DIMENSION, Math.min(width, INTERACTION_CONSTANTS.MAX_DIMENSION)), - height: Math.max(INTERACTION_CONSTANTS.MIN_DIMENSION, Math.min(height, INTERACTION_CONSTANTS.MAX_DIMENSION)) + width: Math.max(INTERACTION_CONSTANTS.MIN_DIMENSION, Math.min(width, INTERACTION_CONSTANTS.MAX_WIDTH)), + height: Math.max(INTERACTION_CONSTANTS.MIN_DIMENSION, Math.min(height, INTERACTION_CONSTANTS.MAX_HEIGHT)) }; } diff --git a/tests/clip-interaction.test.ts b/tests/clip-interaction.test.ts index 51b97eee..733070a9 100644 --- a/tests/clip-interaction.test.ts +++ b/tests/clip-interaction.test.ts @@ -24,8 +24,9 @@ describe("ClipInteractionSystem", () => { expect(INTERACTION_CONSTANTS.MIN_DIMENSION).toBe(50); }); - it("has correct maximum dimension", () => { - expect(INTERACTION_CONSTANTS.MAX_DIMENSION).toBe(3840); + it("has correct maximum dimensions", () => { + expect(INTERACTION_CONSTANTS.MAX_WIDTH).toBe(3840); + expect(INTERACTION_CONSTANTS.MAX_HEIGHT).toBe(2160); }); }); @@ -425,7 +426,7 @@ describe("ClipInteractionSystem", () => { it("clamps width above maximum", () => { const result = clampDimensions(5000, 100); - expect(result.width).toBe(INTERACTION_CONSTANTS.MAX_DIMENSION); + expect(result.width).toBe(INTERACTION_CONSTANTS.MAX_WIDTH); expect(result.height).toBe(100); }); @@ -433,7 +434,7 @@ describe("ClipInteractionSystem", () => { const result = clampDimensions(100, 5000); expect(result.width).toBe(100); - expect(result.height).toBe(INTERACTION_CONSTANTS.MAX_DIMENSION); + expect(result.height).toBe(INTERACTION_CONSTANTS.MAX_HEIGHT); }); it("preserves valid dimensions", () => { @@ -447,7 +448,7 @@ describe("ClipInteractionSystem", () => { const result = clampDimensions(30, 5000); expect(result.width).toBe(INTERACTION_CONSTANTS.MIN_DIMENSION); - expect(result.height).toBe(INTERACTION_CONSTANTS.MAX_DIMENSION); + expect(result.height).toBe(INTERACTION_CONSTANTS.MAX_HEIGHT); }); it("handles boundary values", () => { @@ -455,9 +456,9 @@ describe("ClipInteractionSystem", () => { expect(minResult.width).toBe(50); expect(minResult.height).toBe(50); - const maxResult = clampDimensions(3840, 3840); + const maxResult = clampDimensions(3840, 2160); expect(maxResult.width).toBe(3840); - expect(maxResult.height).toBe(3840); + expect(maxResult.height).toBe(2160); }); });