Skip to content

fix(cdk/virtual-scroll): fix subpixel rounding errors on hdpi screens #16269

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

Merged
merged 2 commits into from
Aug 12, 2019

Conversation

mmalerba
Copy link
Contributor

@mmalerba mmalerba commented Jun 11, 2019

Using transform appears to cause rounding errors that can accumulate and
become significant after scrolling through a large number of items.
Switching to width / height corrects this.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 11, 2019
@mmalerba mmalerba changed the title wip: try using width/height for virtual scroll spacer sizing fix(cdk/virtual-scroll): fix subpixel rounding errors on hdpi screens Jun 21, 2019
@mmalerba mmalerba requested a review from jelbourn June 21, 2019 21:40
@mmalerba mmalerba added G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed P2 The issue is important to a large percentage of users, with a workaround labels Jun 21, 2019
@mmalerba mmalerba marked this pull request as ready for review June 21, 2019 21:41
@mmalerba mmalerba added the target: patch This PR is targeted for the next patch release label Jun 21, 2019
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jun 21, 2019
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -9,4 +9,6 @@
Spacer used to force the scrolling container to the correct size for the *total* number of items
so that the scrollbar captures the size of the entire data set.
-->
<div class="cdk-virtual-scroll-spacer" [style.transform]="_totalContentSizeTransform"></div>
<div class="cdk-virtual-scroll-spacer"
[style.width]="orientation == 'horizontal' ? _totalContentSize + 'px' : ''"
Copy link
Member

Choose a reason for hiding this comment

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

nit: it might be micro-optimizing a bit, but would it make sense to have this logic inside the component when setting _totalContentSize? Otherwise Angular will run the ternary and the string concatenation on each change detection run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, probably a good idea

Using `transform` appears to cause rounding errors that can accumulate and
become significant after scrolling through a large number of items.
Switching to `width` / `height` corrects this.
@mmalerba mmalerba merged commit b796b6e into angular:master Aug 12, 2019
@mmalerba mmalerba deleted the vs-hw branch August 12, 2019 17:19
mmalerba added a commit that referenced this pull request Aug 14, 2019
* fix(cdk/virtual-scroll): fix subpixel rounding errors on hdpi screens

Using `transform` appears to cause rounding errors that can accumulate and
become significant after scrolling through a large number of items.
Switching to `width` / `height` corrects this.

* don't recalulate height/width during every change detection

(cherry picked from commit b796b6e)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement G This is is related to a Google internal issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants