From e6560f96a25756e4c9b5745f33fe362dc2234886 Mon Sep 17 00:00:00 2001 From: Darrell Date: Mon, 18 Nov 2024 16:39:27 -0500 Subject: [PATCH] Minor tweaks to copy coordinates functionality (#867) --- src/ui/src/lib/MapCoordinates.svelte | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ui/src/lib/MapCoordinates.svelte b/src/ui/src/lib/MapCoordinates.svelte index 2986d100..6de0f295 100644 --- a/src/ui/src/lib/MapCoordinates.svelte +++ b/src/ui/src/lib/MapCoordinates.svelte @@ -42,14 +42,17 @@ if ((event.ctrlKey || event.metaKey) && event.key === 'c') { event.preventDefault(); hasFocus = true; - const coords = ` - [${cursorX.toFixed(2)},${cursorY.toFixed(2)}]`; + const roundedX = Math.round(cursorX * 10) / 10; + const roundedY = Math.round(cursorY * 10) / 10; + const coords = ` - [${roundedX},${roundedY}]`; copiedCoords = [...copiedCoords, coords]; navigator.clipboard .writeText(copiedCoords.join('\n')) .then(() => { toastStore.trigger({ message: `Copied ${copiedCoords.length} coordinate${copiedCoords.length > 1 ? 's' : ''} to clipboard!`, - background: 'variant-filled-success' + background: 'variant-filled-success', + timeout: 1000 }); }) .catch((error) => { @@ -67,7 +70,8 @@ copiedCoords = []; toastStore.trigger({ message: 'Coordinate collection reset', - background: 'variant-filled-primary' + background: 'variant-filled-primary', + timeout: 1000 }); } } @@ -78,6 +82,6 @@ - X: {cursorX.toFixed(2)}, Y: {cursorY.toFixed(2)} + X: {Math.round(cursorX * 10) / 10}, Y: {Math.round(cursorY * 10) / 10}