LB-1965 : smooth progress bar animation with drag-to-seek#3664
Open
Gopal7387 wants to merge 11 commits intometabrainz:masterfrom
Open
LB-1965 : smooth progress bar animation with drag-to-seek#3664Gopal7387 wants to merge 11 commits intometabrainz:masterfrom
Gopal7387 wants to merge 11 commits intometabrainz:masterfrom
Conversation
… keyboard seek fix
…ight bar background
…le playhead indicator
…revent handle clipping
Contributor
Author
|
Hi @anshg1214 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The BrainzPlayer progress bar had some problems. LB-1965
It had two issues.
The first issue with the BrainzPlayer progress bar was that the playback animation did not move smoothly. Also BrainzPlayer progress bar animation was controlled by React state updates that happened every 300 milliseconds, which made the BrainzPlayer progress bar jump in steps of moving smoothly.
The second issue with the BrainzPlayer progress bar was that you could not drag the BrainzPlayer progress bar to change the position of the playback.
You could only click on a position, on the BrainzPlayer progress bar to change the playback position.
Solution
Replaced the React state-driven
width%approach with arequestAnimationFrameloop that writestransform: scaleX()directlyto the DOM via a ref. This gives true 60fps animation with zero React
re-renders per frame.
Added a circular scrubber handle that appears on hover and follows the
playhead. Users can now click and drag anywhere on the bar to seek.
What changed
ProgressBar.tsx
performance.now() - updateTimeto interpolate liveplayhead position between atom updates
progressBarInnerRefreceives directscaleXwrites — no setStatein the animation path
isDraggingRef,rectCacheRef,pendingSeekMsRefto coordinatedrag state without touching React
pointermove/pointeruplisteners so drag workseven if mouse leaves the bar
pendingSeekMsRefholds the optimistic position after seek fires,preventing the bar from snapping back while the player catches up
pendingSeekMsReffor the same snap-free behaviour
cursor: grabbingondocument.bodyduring active dragbrainzplayer.scss
width: 100%to.progress-bar(required for scaleX base)overflow: visibleto.progressto unclip the handle.draggingrule to pin bar height during drag.progress-handlestyles (14px circle,$primary-color,hover-only via
scaleXtransition)border-rightnubbin — the handle replaces itTesting
Tested locally with a YouTube-backed track:
leaves the element
.music-playerfullscreen view unaffectedNotes
Handle color and hover-only behaviour confirmed with @Aerozol . No new colours introduced.
AI usage:
If you did use AI:
[ ] I used AI tools for communication
[ ] I used AI tools for coding
[ ] I understand all the changes made in this PR
Screen.Recording.2026-04-02.at.1.02.40.AM.1.1.mov