File size: 1,133 Bytes
4e1096a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | import { ViewSettings } from '@/types/book';
export const getMaxInlineSize = (viewSettings: ViewSettings) => {
const isVertical = viewSettings.vertical;
const screenWidth = window.innerWidth;
const screenHeight = window.innerHeight;
const screenAspectRatio = isVertical ? screenHeight / screenWidth : screenWidth / screenHeight;
const isUnfoldedScreen = screenAspectRatio < 1.3 && screenAspectRatio > 0.77 && screenWidth > 600;
return isVertical
? Math.max(screenWidth, screenHeight, 720, viewSettings.maxInlineSize)
: isUnfoldedScreen
? viewSettings.maxInlineSize * 0.8
: viewSettings.maxInlineSize;
};
export const getDefaultMaxInlineSize = () => {
if (typeof window === 'undefined') return 720;
const screenWidth = window.innerWidth;
const screenHeight = window.innerHeight;
return screenWidth < screenHeight ? Math.max(screenWidth, 720) : 720;
};
export const getDefaultMaxBlockSize = () => {
if (typeof window === 'undefined') return 1440;
const screenWidth = window.innerWidth;
const screenHeight = window.innerHeight;
return Math.max(screenWidth, screenHeight, 1440);
};
|