Created
October 1, 2023 09:26
-
-
Save yinkakun/660e7bc7abcc8d5d76ff2519d5897c90 to your computer and use it in GitHub Desktop.
is mobile?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function isAndroid(): boolean { | |
return ( | |
typeof navigator !== 'undefined' && /android/i.test(navigator.userAgent) | |
); | |
} | |
export function isSmallIOS(): boolean { | |
return ( | |
typeof navigator !== 'undefined' && /iPhone|iPod/.test(navigator.userAgent) | |
); | |
} | |
export function isLargeIOS(): boolean { | |
return ( | |
typeof navigator !== 'undefined' && | |
(/iPad/.test(navigator.userAgent) || | |
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) | |
); | |
} | |
export function isIOS(): boolean { | |
return isSmallIOS() || isLargeIOS(); | |
} | |
export function isMobile(): boolean { | |
return isAndroid() || isIOS(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment