feat: Introduce new LayoutSystem and spatial workspace architecture design document, refactor document card and workspace to use it, and simplify pointer event handling.
This commit is contained in:
@@ -33,3 +33,22 @@ export const computeCardBounds = ({
|
||||
maxY: Math.max(padding + halfH, canvasHeight - padding - halfH),
|
||||
};
|
||||
};
|
||||
|
||||
export const constrainDimensions = (width: number, height: number, maxDimension: number) => {
|
||||
if (width <= maxDimension && height <= maxDimension) {
|
||||
return { width, height };
|
||||
}
|
||||
|
||||
const aspect = width / height;
|
||||
if (width > height) {
|
||||
return {
|
||||
width: maxDimension,
|
||||
height: maxDimension / aspect
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
width: maxDimension * aspect,
|
||||
height: maxDimension
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user