add mobile device detection and redirect to external site
This commit is contained in:
21
src/utils/deviceDetection.ts
Normal file
21
src/utils/deviceDetection.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
function isPortraitAndNarrow(): boolean {
|
||||
return window.innerWidth < window.innerHeight && window.innerWidth < 768;
|
||||
}
|
||||
|
||||
export function isMobileDevice(): boolean {
|
||||
const toMatch = [
|
||||
/Android/i,
|
||||
/webOS/i,
|
||||
/iPhone/i,
|
||||
/iPad/i,
|
||||
/iPod/i,
|
||||
/BlackBerry/i,
|
||||
/Windows Phone/i
|
||||
];
|
||||
|
||||
const isMobileUserAgent = toMatch.some((toMatchItem) => {
|
||||
return navigator.userAgent.match(toMatchItem);
|
||||
});
|
||||
|
||||
return isMobileUserAgent || isPortraitAndNarrow();
|
||||
}
|
Reference in New Issue
Block a user