Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

browserDeviceToolbarState.ts

18 lines611 Bytes

1import type { PreviewViewportSetting } from "@t3tools/contracts";
2​
3export function reconcileLockedAspectRatio(
4 current: number | null,
5 viewportAspectRatio: number | null,
6): number | null {
7 return current === null || viewportAspectRatio === null ? null : viewportAspectRatio;
8}
9​
10export async function commitViewportAndAspectRatio(
11 setting: PreviewViewportSetting,
12 aspectRatio: number | null,
13 onChange: (setting: PreviewViewportSetting) => Promise<void>,
14 onAspectRatioChange: (aspectRatio: number | null) => void,
15): Promise<void> {
16 await onChange(setting);
17 onAspectRatioChange(aspectRatio);