Skip to content

Commit f512da6

Browse files
feat: add noMouse state to handle button visibility for touch devices
1 parent f91a134 commit f512da6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/routes/+page.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
let watermark = $state(false)
1010
let hex = $state("#ffffff")
1111
let retry: number | null = $state(null)
12+
let noMouse = $state(false)
1213
1314
let clippyCanvas: (HTMLCanvasElement | null)[] = $state(Array.from({ length: clippyCount }, (_) => null));
1415
let clippyImages: (HTMLImageElement | null)[] = $state(Array.from({ length: clippyCount }, (_) => null));
@@ -91,8 +92,11 @@
9192
9293
onMount(()=>{
9394
if (!browser) return;
94-
9595
retry = setInterval(renderClippys, 1000);
96+
97+
if(window.matchMedia("(any-hover: none)").matches) {
98+
noMouse = true;
99+
}
96100
})
97101
98102
</script>
@@ -147,7 +151,7 @@
147151

148152
{#each clippys as _, clippyIndex}
149153
<div class="group relative flex flex-col place-items-center place-content-center aspect-square rounded-lg border border-black/30">
150-
<button onclick={()=>download(clippyIndex)} class="group-hover:block hidden absolute top-2 right-2 rounded-lg bg-white border text-black/90 border-black/30 p-2 cursor-pointer" aria-label="Download">
154+
<button onclick={()=>download(clippyIndex)} class="{noMouse ? '' : 'group-hover:block md:hidden'} absolute top-2 right-2 rounded-lg bg-white border text-black/90 border-black/30 p-2 cursor-pointer" aria-label="Download">
151155
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256"><path opacity="1" d="M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z"></path></svg>
152156
</button>
153157
{#if clippyLoading[clippyIndex]}

0 commit comments

Comments
 (0)