From 71adbe921e79d61a0ff3fe7b2b73098c8babbe2b Mon Sep 17 00:00:00 2001 From: thewh1teagle <61390950+thewh1teagle@users.noreply.github.com> Date: Wed, 5 Jun 2024 21:12:57 +0300 Subject: [PATCH] improve landing mobile detect --- landing/src/components/Cta.svelte | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/landing/src/components/Cta.svelte b/landing/src/components/Cta.svelte index b4c4f5cf..9143a02e 100644 --- a/landing/src/components/Cta.svelte +++ b/landing/src/components/Cta.svelte @@ -7,7 +7,6 @@ import GithubIcon from '~/icons/Github.svelte' import ChipIcon from '~/icons/Chip.svelte' import latestRelease from '$lib/latest_release.json' - import Logo from '~/icons/Logo.svelte' let asset = latestRelease.assets.find((a) => a.platform.toLowerCase() === 'macos') // default to macos let ctaClicked = false @@ -18,8 +17,10 @@ const macSiliconAsset = latestRelease.assets.find((a) => a.platform.toLowerCase() === 'macos' && a.arch === 'darwin-aarch64') let mobileModalOpen = false + let isMobile = false + function ctaClick() { - if (window.navigator.maxTouchPoints > 0) { + if (isMobile) { // is mobile mobileModalOpen = true } else { @@ -58,6 +59,19 @@ currentURL = location.href }) + onMount(() => { + function checkIsMobile() { + var match = window.matchMedia || (window as any).msMatchMedia + if (match) { + var mq = match('(pointer:coarse)') + return mq.matches + } + return false + } + + isMobile = checkIsMobile() + }) + const t = $i18n.t