mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-24 17:51:51 +02:00
[web] Add stricter mobile detection for context menu GitOrigin-RevId: 9c9e75a14c1f9841b5125cb4fb4ef8c2f3b8a33f
16 lines
558 B
TypeScript
16 lines
558 B
TypeScript
import browser from '../extensions/browser'
|
|
|
|
export function isMobileDevice(): boolean {
|
|
const ua = typeof navigator !== 'undefined' ? navigator.userAgent : ''
|
|
const isMobileUserAgent = /Android|iPhone|iPad|Mobile/i.test(ua)
|
|
|
|
// Input-capability fallback.
|
|
const isTouchOnlyInput =
|
|
typeof window !== 'undefined' &&
|
|
typeof window.matchMedia === 'function' &&
|
|
window.matchMedia('(pointer: coarse)').matches &&
|
|
window.matchMedia('(hover: none)').matches
|
|
|
|
return browser.ios || browser.android || isMobileUserAgent || isTouchOnlyInput
|
|
}
|