Skip to content

Commit 982cf2a

Browse files
authored
fix(AudioPlayback): improve wave progress bar smoothness and sizing (#3094)
### 🎯 Goal The wave progress bar indicator jumps between positions during playback and the waveform stops growing after a certain width, making the audio player feel janky. ### πŸ›  Implementation details - **Smooth playback transitions:** Added 250ms linear CSS transitions on the progress indicator (`inset-inline-start`) and amplitude bars (`background`). The 250ms duration matches the browser's `timeupdate` firing interval, so the indicator glides continuously between updates. - **Instant drag response:** Added a `--dragging` modifier class toggled via `useInteractiveProgressBar`. While active, transitions are disabled so the handle tracks the pointer without lag. - **Wave bar sizing:** Added `flex: 1` to the `__metadata` container so the wave bar fills all available space instead of being capped at content width. ### 🎨 UI Changes - Progress indicator glides smoothly during playback instead of jumping bar-to-bar - Amplitude bar colors fade smoothly between active/inactive states - Wave bar now stretches to fill the full width of the voice recording widget - Dragging the handle remains instant with no transition lag
1 parent d313317 commit 982cf2a

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

β€Žsrc/components/Attachment/styling/Attachment.scssβ€Ž

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
.str-chat {
44
/* The margin applied to every attachment in the attachment list */
5-
--str-chat__attachment-margin: var(--space-2)
6-
/* The border radius used for the borders of the component */
7-
--str-chat__attachment-list-border-radius: 0;
5+
--str-chat__attachment-margin: var(--space-2);
6+
/* The border radius used for the borders of the component */
7+
--str-chat__attachment-list-border-radius: 0;
88

99
/* The text/icon color of the component */
1010
--str-chat__attachment-list-color: var(--str-chat__text-color);
@@ -425,6 +425,7 @@
425425
}
426426

427427
.str-chat__message-attachment__voice-recording-widget__metadata {
428+
flex: 1;
428429
min-width: 180px;
429430
padding-inline: var(--spacing-xs);
430431

β€Žsrc/components/AudioPlayback/components/useInteractiveProgressBar.tsβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const useInteractiveProgressBar = ({
5151

5252
isDragging.current = true;
5353
progressIndicator.style.cursor = 'grabbing';
54+
root?.classList.add('str-chat__wave-progress-bar__track--dragging');
5455
};
5556

5657
const handleDrag: PointerEventHandler<HTMLDivElement> = (e) => {
@@ -64,7 +65,8 @@ export const useInteractiveProgressBar = ({
6465

6566
isDragging.current = false;
6667
progressIndicator.style.removeProperty('cursor');
67-
}, [progressIndicator]);
68+
root?.classList.remove('str-chat__wave-progress-bar__track--dragging');
69+
}, [progressIndicator, root]);
6870

6971
useEffect(() => {
7072
document.addEventListener('pointerup', handleDragStop);

β€Žsrc/components/AudioPlayback/styling/WaveProgressBar.scssβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,30 @@
4242
width: 14px;
4343
border-radius: var(--radius-max);
4444
cursor: grab;
45+
transition: inset-inline-start 250ms linear;
4546
}
4647
}
4748

4849
.str-chat__wave-progress-bar__amplitude-bar {
4950
background: var(--chat-waveform-bar);
5051
border-radius: var(--radius-max);
52+
transition: background 250ms linear;
5153
}
5254

5355
.str-chat__wave-progress-bar__amplitude-bar--active {
5456
background: var(--chat-waveform-bar-playing);
5557
}
5658

59+
.str-chat__wave-progress-bar__track--dragging {
60+
.str-chat__wave-progress-bar__progress-indicator {
61+
transition: none;
62+
}
63+
64+
.str-chat__wave-progress-bar__amplitude-bar {
65+
transition: none;
66+
}
67+
}
68+
5769
.str-chat__wave-progress-bar__track--playback-initiated {
5870
.str-chat__wave-progress-bar__progress-indicator {
5971
background: var(--accent-primary);

0 commit comments

Comments
Β (0)