mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-14 10:09:31 -07:00
fix: improve mobile device detection reliability
Signed-off-by: Sped0n <hi@sped0n.com>
This commit is contained in:
@@ -38,9 +38,14 @@ const Mobile = lazy(async () => await import('./mobile/layout'))
|
|||||||
function Main(): JSX.Element {
|
function Main(): JSX.Element {
|
||||||
// variables
|
// variables
|
||||||
const [ijs] = createResource(getImageJSON)
|
const [ijs] = createResource(getImageJSON)
|
||||||
const isMobile =
|
const ua = window.navigator.userAgent.toLowerCase()
|
||||||
window.matchMedia('(hover: none)').matches &&
|
const hasTouchInput = 'ontouchstart' in window || window.navigator.maxTouchPoints > 0
|
||||||
!window.navigator.userAgent.includes('Win')
|
const hasTouchLayout =
|
||||||
|
window.matchMedia('(pointer: coarse)').matches ||
|
||||||
|
window.matchMedia('(hover: none)').matches
|
||||||
|
const isMobileUA = /android|iphone|ipad|ipod|mobile/.test(ua)
|
||||||
|
const isWindowsDesktop = /windows nt/.test(ua)
|
||||||
|
const isMobile = isMobileUA || (hasTouchInput && hasTouchLayout && !isWindowsDesktop)
|
||||||
|
|
||||||
// states
|
// states
|
||||||
const [scrollable, setScollable] = createSignal(true)
|
const [scrollable, setScollable] = createSignal(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user