Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Improve scroll position adjustments on zoom in/out #3518

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

brian-byassee
Copy link
Contributor

@brian-byassee brian-byassee commented Jan 25, 2024

Short description

The playhead position can drift a lot during zoom operations. Especially when zooming out when the playhead is at the end.

This PR improves the accuracy of the offset needed to scrollLeft to keep the playhead visible. It does this by adding 1/2 pixel values to the scrollLeft

(1/2 pixels is the level of precision supported with scrollbars)

Resolves #
Limits issue where playhead ends up off screen durning zoom operations.

Implementation details

How to test it

Using the Basic Zoom

Zoom out and set play head towards the end.
Zoom in to the play head
Then zoom out.
Note that the playhead is immediately lost on zoom out

Screenshots

With updates
https://github.com/katspaugh/wavesurfer.js/assets/47955954/f5ab9031-c080-45ab-995c-1a0ff3b5bf7c

Without updates

Broken.mov

Checklist

  • This PR is covered by e2e tests
  • It introduces no breaking API changes

Copy link
Owner

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

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

Interesting! I didn’t even realize there was a rounding issue.

@katspaugh katspaugh merged commit fad4ec1 into katspaugh:main Jan 26, 2024
2 checks passed
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.

None yet

2 participants