GraphReFlyTS

API Reference

fitSize()

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

Import

import { fitSize } from "@graphrefly/ts/solutions/reactive-layout";

Signature

function fitSize(
	size: Size,
	maxWidth: number,
): Size

Parameters

ParameterTypeDescription
sizeSizeInput size.
maxWidthnumberMaximum width constraint.

Returns

The fitted size.

Example

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

Source

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