-
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
777c19e
commit 99706df
Showing
4 changed files
with
42 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export function isMobileFirefox(): boolean | undefined { | ||
const userAgent = navigator.userAgent; | ||
return ( | ||
typeof window !== 'undefined' && | ||
((/Firefox/.test(userAgent) && /Mobile/.test(userAgent)) || // Android Firefox | ||
/FxiOS/.test(userAgent)) // iOS Firefox | ||
); | ||
} | ||
|
||
export function isMac(): boolean | undefined { | ||
return testPlatform(/^Mac/); | ||
} | ||
|
||
export function isIPhone(): boolean | undefined { | ||
return testPlatform(/^iPhone/); | ||
} | ||
|
||
export function isSafari(): boolean | undefined { | ||
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent); | ||
} | ||
|
||
export function isIPad(): boolean | undefined { | ||
return ( | ||
testPlatform(/^iPad/) || | ||
// iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support. | ||
(isMac() && navigator.maxTouchPoints > 1) | ||
); | ||
} | ||
|
||
export function isIOS(): boolean | undefined { | ||
return isIPhone() || isIPad(); | ||
} | ||
|
||
export function testPlatform(re: RegExp): boolean | undefined { | ||
return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator.platform) : undefined; | ||
} |
This file contains 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
This file contains 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
This file contains 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