Skip to content

Commit

Permalink
fix isMobile
Browse files Browse the repository at this point in the history
  • Loading branch information
codingki committed Sep 28, 2024
1 parent 41bf4ac commit de1ab01
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/graz/src/utils/os.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
export const isMobile = () => {
if (typeof window !== "undefined") {
return Boolean(
window.matchMedia("(pointer:coarse)").matches ||
/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent),
);
const userAgent = navigator.userAgent;

// Check for common mobile devices by examining user agent strings
if (/android/i.test(userAgent)) {
return true;
}

if (/iPad|iPhone|iPod/.test(userAgent)) {
return true;
}

return false;
}

return false;
Expand Down

0 comments on commit de1ab01

Please sign in to comment.