mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-13 08:48:38 +01:00
add broker
This commit is contained in:
16
broker/src/ScreenSize.ts
Normal file
16
broker/src/ScreenSize.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
|
||||
export function getDeviceFromScreenSize(width: number, height: number) {
|
||||
const totalArea = width * height;
|
||||
|
||||
const mobileArea = 375 * 667;
|
||||
const tabletMinArea = 768 * 1366
|
||||
const tabletMaxArea = 1024 * 1366
|
||||
|
||||
const isMobile = totalArea <= mobileArea;
|
||||
const isTablet = totalArea >= tabletMinArea && totalArea <= tabletMaxArea;
|
||||
|
||||
if (isMobile) return 'mobile';
|
||||
if (isTablet) return 'tablet'
|
||||
return 'desktop';
|
||||
}
|
||||
Reference in New Issue
Block a user