Skip to content

Fix Sync Scroll#372

Open
amitojsingh wants to merge 4 commits intodevfrom
fix-seeking
Open

Fix Sync Scroll#372
amitojsingh wants to merge 4 commits intodevfrom
fix-seeking

Conversation

@amitojsingh
Copy link
Collaborator

The synchronization scrolling issue has been resolved. Previously, seeking forward or backward did not scroll to the desired page. This issue has been fixed in the PR.

…nd UI responsiveness

- Updated handleSeek function in AudioPlayer to use useCallback for better performance.
- Enhanced AudioControlBar with new slider handling logic, including optimistic updates during dragging.
- Implemented state management for slider value and seek loading to improve user experience.
- Added scroll state reset functionality in useAudioSyncScroll to handle seeking more effectively.
Copy link
Collaborator

@Gauravjeetsingh Gauravjeetsingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor change, plus some clarity needed for the logic used.

Comment on lines 307 to 314
// Prevent concurrent seeks
if (isSeekingRef.current || !isAudioEnabled) {
setIsSliding(false);
return;
}

// Update UI immediately (optimistic update)
setIsSliding(false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setIsSliding(false) is repeating here. So we can setIsSliding before if, and inside if we can just return.

const previousPosition = previousPositionRef.current;

// Detect seek: if position jumps more than 2 seconds, it's likely a seek
// Normal playback won't jump more than ~1 second per update
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get this logic. What do we mean by a normal update here?

@amitojsingh amitojsingh changed the title Refactor AudioPlayer and AudioControlBar for improved seek handling a… Fix Sync Scroll Jan 7, 2026
- Added setIsSeekLoading(false) to ensure loading state is reset after seeking operations.
- Updated test timeouts for better reliability in asynchronous tests.
- Improved test assertions for slider state and function calls to enhance clarity and maintainability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants