Skip to content
PACKAGES

fitSize()

Fit a size within a maximum width while preserving aspect ratio.

import { fitSize } from "@graphrefly/ts/solutions/reactive-layout";
function fitSize(
size: Size,
maxWidth: number,
): Size
ParameterTypeDescription
sizeSizeInput size.
maxWidthnumberMaximum width constraint.

The fitted size.

fitSize({ width: 200, height: 100 }, 50);

packages/ts/src/solutions/reactive-layout/utils.ts