Skip to content

Conversation

@baiyuanneko
Copy link
Contributor

@baiyuanneko baiyuanneko commented Nov 16, 2025

Since I added the scrollbar feature to the track list page, I noticed an issue: after dragging the scrollbar with the left mouse button, using the mouse wheel would cause the scrollbar to jump back to the far left.
This pull request fixes that problem.

Summary by Sourcery

Fix scrollbar jumping by synchronizing the smooth scroll controller’s internal value with external scroll events and cleaning up listeners

Bug Fixes:

  • Prevent scrollbar from snapping back after dragging by syncing the lerp controller value on external scrolls

Enhancements:

  • Expose LerpController.isAnimating and add syncValue method for manual value updates

Chores:

  • Remove scroll listener on dispose to avoid potential memory leaks

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 16, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Introduce external scroll event handling in SmoothScrollController and extend LerpController to support direct value synchronization, ensuring the scrollbar’s position remains in sync after mouse interactions.

Sequence diagram for external scroll event handling in SmoothScrollController

sequenceDiagram
participant User as actor User
participant Scrollbar
participant SmoothScrollController
participant LerpController

User->>Scrollbar: Drag scrollbar (mouse down/move)
Scrollbar->>SmoothScrollController: Update offset
SmoothScrollController->>LerpController: syncValue(offset) (if not animating)
User->>Scrollbar: Use mouse wheel
Scrollbar->>SmoothScrollController: Update offset
SmoothScrollController->>LerpController: syncValue(offset) (if not animating)
Loading

Class diagram for updated SmoothScrollController and LerpController

classDiagram
class SmoothScrollController {
  +void smoothScrollBy(double delta)
  +void dispose()
  +void _handleExternalScroll()
}
SmoothScrollController --|> ScrollController
SmoothScrollController o-- LerpController : uses

class LerpController {
  +void syncValue(double value)
  +bool isAnimating
  +double get value
}
Loading

File-Level Changes

Change Details Files
Sync SmoothScrollController offset to LerpController on external scroll
  • Add listener in constructor for external scroll events
  • Implement _handleExternalScroll to update controller when not animating
  • Remove listener in dispose to prevent leaks
lib/widgets/smooth_horizontal_scroll.dart
Expose LerpController sync and animation state APIs
  • Add syncValue(double) to set internal value
  • Introduce isAnimating getter based on ticker state
lib/utils/lerp_controller.dart

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dosubot dosubot bot added the C - UI UI related issue label Nov 16, 2025
@Losses
Copy link
Owner

Losses commented Nov 18, 2025

Cool, LGTM, Thanks!

@Losses Losses merged commit 5bb6ebe into Losses:master Nov 18, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C - UI UI related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants