mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2025-12-06 12:20:20 +01:00
16 lines
545 B
TypeScript
16 lines
545 B
TypeScript
import { TASKBAR_HEIGHT, TITLEBAR_HEIGHT } from '@/utils/constants';
|
|
|
|
export const getLockedAspectRatioDimensions = (
|
|
width: number,
|
|
height: number
|
|
): { width: string | number; height: string | number } => {
|
|
const aspectRatio = width / (height - TITLEBAR_HEIGHT);
|
|
const adjustedHeight = window.innerHeight - TASKBAR_HEIGHT - TITLEBAR_HEIGHT;
|
|
const widerWidth = window.innerWidth / adjustedHeight < aspectRatio;
|
|
|
|
return {
|
|
width: widerWidth ? '100%' : adjustedHeight * aspectRatio,
|
|
height: widerWidth ? 'auto' : '100%'
|
|
};
|
|
};
|