diff --git a/src/lib/components/AudioOutputBadges.svelte b/src/lib/components/AudioOutputBadges.svelte index 5d9d82efb..04f8f11d9 100644 --- a/src/lib/components/AudioOutputBadges.svelte +++ b/src/lib/components/AudioOutputBadges.svelte @@ -45,6 +45,14 @@ let hardwareStatus = $state(null); let isHovering = $state(false); + // Ticker animation for long device names + let deviceNameRef: HTMLDivElement | null = $state(null); + let deviceNameTextRef: HTMLSpanElement | null = $state(null); + let deviceNameOverflow = $state(0); + const deviceNameOffset = $derived(deviceNameOverflow > 0 ? `-${deviceNameOverflow + 16}px` : '0px'); + const tickerSpeed = 80; // pixels per second + const deviceNameDuration = $derived(deviceNameOverflow > 0 ? `${(deviceNameOverflow + 16) / tickerSpeed}s` : '0s'); + // Derived state const currentDevice = $derived(outputStatus?.device_name ?? null); @@ -147,6 +155,23 @@ } } + // Update outputStatus when hovering to get fresh device name + $effect(() => { + if (isHovering && !outputStatus) { + invoke('get_audio_output_status') + .then(status => outputStatus = status) + .catch(() => {}); + } + }); + + // Calculate overflow for ticker animation when tooltip is visible + $effect(() => { + if (isHovering && deviceNameRef && deviceNameTextRef) { + const overflow = deviceNameTextRef.scrollWidth - deviceNameRef.clientWidth; + deviceNameOverflow = overflow > 0 ? overflow : 0; + } + }); + onMount(() => { loadStatus(); @@ -170,6 +195,8 @@
isHovering = true} onmouseleave={() => isHovering = false} > @@ -205,7 +232,16 @@
Output Device
-
{prettyDeviceName}
+
0} + style="--ticker-offset: {deviceNameOffset}; --ticker-duration: {deviceNameDuration};" + bind:this={deviceNameRef} + > + + {prettyDeviceName} + +
{#if currentDevice && currentDevice !== prettyDeviceName}
{currentDevice}
{/if} @@ -367,6 +403,25 @@ text-overflow: ellipsis; } + .tooltip-device.scrollable { + text-overflow: clip; + } + + .device-name-text { + display: inline-block; + white-space: nowrap; + } + + .device-tooltip:hover .tooltip-device.scrollable .device-name-text { + animation: device-name-ticker var(--ticker-duration) linear infinite; + will-change: transform; + } + + @keyframes device-name-ticker { + from { transform: translateX(0); } + to { transform: translateX(var(--ticker-offset)); } + } + .tooltip-raw { font-size: 9px; color: rgba(255, 255, 255, 0.3);