Skip to content

Commit 6341962

Browse files
authored
fix(web): better touch device detection (#17144)
* fix(web): better touch device detection * variable name
1 parent c26b28f commit 6341962

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Diff for: web/src/lib/components/assets/thumbnail/thumbnail.svelte

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
IMAGE_THUMBNAIL: { THUMBHASH_FADE_DURATION },
7373
} = TUNABLES;
7474
75-
let isTouchDevice = $derived(mobileDevice.hoverNone);
75+
let usingMobileDevice = $derived(mobileDevice.pointerCoarse);
7676
let focussableElement: HTMLElement | undefined = $state();
7777
let mouseOver = $state(false);
7878
let loaded = $state(false);
@@ -112,7 +112,7 @@
112112
};
113113
114114
const onMouseEnter = () => {
115-
if (isTouchDevice) {
115+
if (usingMobileDevice) {
116116
return;
117117
}
118118
mouseOver = true;
@@ -191,7 +191,7 @@
191191
onfocus={handleFocus}
192192
data-testid="container-with-tabindex"
193193
>
194-
{#if !isTouchDevice && mouseOver && !disableMouseOver}
194+
{#if !usingMobileDevice && mouseOver && !disableMouseOver}
195195
<!-- lazy show the url on mouse over-->
196196
<a
197197
class="absolute z-30 {className} top-[41px]"
@@ -238,7 +238,7 @@
238238
class:rounded-xl={selected}
239239
>
240240
<!-- Gradient overlay on hover -->
241-
{#if !isTouchDevice}
241+
{#if !usingMobileDevice}
242242
<div
243243
class="absolute z-10 h-full w-full bg-gradient-to-b from-black/25 via-[transparent_25%] opacity-0 transition-opacity group-hover:opacity-100"
244244
class:rounded-xl={selected}

Diff for: web/src/lib/components/photos-page/asset-grid.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
let bottomSectionHeight = 60;
8484
let leadout = $state(false);
8585
86-
const usingMobileDevice = $derived(mobileDevice.hoverNone);
86+
const usingMobileDevice = $derived(mobileDevice.pointerCoarse);
8787
8888
const scrollTo = (top: number) => {
8989
element?.scrollTo({ top });

Diff for: web/src/lib/components/shared-components/scrubber/scrubber.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@
268268
globalThis.removeEventListener('touchmove', onTouchMove);
269269
};
270270
});
271-
const usingMobileDevice = $derived(mobileDevice.hoverNone);
271+
const usingMobileDevice = $derived(mobileDevice.pointerCoarse);
272272
</script>
273273

274274
<svelte:window

Diff for: web/src/lib/stores/mobile-device.svelte.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { MediaQuery } from 'svelte/reactivity';
22

3-
const hoverNone = new MediaQuery('hover: none');
3+
const pointerCoarse = new MediaQuery('pointer:coarse');
44
const maxMd = new MediaQuery('max-width: 767px');
55

66
export const mobileDevice = {
7-
get hoverNone() {
8-
return hoverNone.current;
7+
get pointerCoarse() {
8+
return pointerCoarse.current;
99
},
1010
get maxMd() {
1111
return maxMd.current;

0 commit comments

Comments
 (0)