-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(cdk/scrolling): prevent subpixel gaps in virtual scroll viewport #31940
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
fix(cdk/scrolling): prevent subpixel gaps in virtual scroll viewport #31940
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
d4b2a17 to
f591920
Compare
|
@Mr-KRAMA Can you remove the second commit? I think that failure was either a flake or an unrelated issue that can be fixed separately from this PR |
210df2c to
f591920
Compare
|
@mmalerba Thanks for the feedback! I've removed the second commit as requested. How should I approach the lighthouse audit failure? Should it be a separate PR or is it expected to be handled by maintainers? |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This PR fixes the issue where cdk-virtual-scroll-viewport renders visible gaps between items at certain zoom levels or scroll positions.
Problem:
Thin gaps (~0.5px) appear between consecutive rows when using *cdkVirtualFor
Issue occurs due to subpixel rounding in offset calculations
Most noticeable when zooming browser window or at specific scroll positions
Solution:
Added Math.round() to the offset calculation in setRenderedContentOffset()
Ensures all item positions are rounded to whole pixels
Eliminates subpixel gaps while maintaining smooth scrolling
Changes:
Single line change in fixed-size-virtual-scroll.ts
Wraps this._itemSize * newRange.start with Math.round()
Testing
Tested with different zoom levels (300%)
Verified no gaps appear between items during scrolling
Confirmed smooth scrolling behavior is preserved
Fixes #31824