Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
feat: added apple platform detection
Browse files Browse the repository at this point in the history
  • Loading branch information
tmgulland committed May 20, 2024
1 parent f67fc5e commit 7a4b77d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/device.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference lib="dom" />

const hasPlatform = () => typeof navigator !== 'undefined' && navigator.platform
const hasUserAgent = () => typeof navigator !== 'undefined' && navigator.userAgent

export const isChrome = () => {
Expand All @@ -23,4 +24,10 @@ export const isMobile = (): boolean => {
: false
}

export const isApple = () => {
if (!hasPlatform()) return false
const p = typeof navigator === 'object' ? navigator.platform : ''
return /Mac|iPod|iPhone|iPad/.test(p)
}

export const isTouchscreen = () => hasUserAgent() && window.matchMedia('(pointer: coarse)').matches

0 comments on commit 7a4b77d

Please sign in to comment.