bigbuffet-rw/packages/pl-fe/src/is-mobile.ts

16 lines
563 B
TypeScript
Raw Normal View History

2022-04-24 12:28:07 -07:00
/** Breakpoint at which the application is considered "mobile". */
const LAYOUT_BREAKPOINT = 630;
/** Check if the width is small enough to be considered "mobile". */
const isMobile = (width: number) => width <= LAYOUT_BREAKPOINT;
2022-04-24 12:28:07 -07:00
/** Whether the device is iOS (best guess). */
const iOS: boolean = /iPad|iPhone|iPod/.test(navigator.userAgent) && !(window as any).MSStream;
const userTouching = window.matchMedia('(pointer: coarse)');
2022-04-24 12:28:07 -07:00
/** Whether the device is iOS (best guess). */
const isIOS = (): boolean => iOS;
export { isMobile, userTouching, isIOS };