new-home/src/utils/deviceDetection.ts
José Henrique 37ac35e3f4
All checks were successful
Master Build / Build and Push Docker Image (amd64) (push) Successful in 53s
Master Build / Update running container (push) Successful in 10s
add mobile device detection and redirect to external site
2025-01-24 22:16:42 -03:00

22 lines
475 B
TypeScript

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();
}