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

Add rounding to horizontal scroll #262

Merged
merged 1 commit into from
Dec 6, 2017
Merged

Conversation

sergek
Copy link
Contributor

@sergek sergek commented Dec 1, 2017

Description

Add rounding to horizontal scroll to avoid content blurring (in case translate3d is used).

Motivation and Context

Fixes issue:
#254

How Has This Been Tested?

Manually tested in Chrome, Safairi, FF of latest release versions.

Screenshots (if appropriate):

Unrounded
2017-12-01 17 18 21

Rounded
2017-12-01 17 18 45

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [ x] My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • [x ] I have read the CONTRIBUTING document.

@@ -1426,10 +1426,13 @@ var FixedDataTable = createReactClass({
if (!this._isScrolling) {
this._didScrollStart();
}

var roundedScrollPos = Math.round(scrollPos);
Copy link
Member

@wcjordan wcjordan Dec 1, 2017

Choose a reason for hiding this comment

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

Awesome, thanks for digging ito this more. Do we need to do the same thing when we set scrollX in _onScroll? Is it worth doing for scrollY as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For _onScroll there is no need as it doesn't directly change dom.
And there is rounding in scrollY already in place.

Copy link
Member

Choose a reason for hiding this comment

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

Could you elaborate on your comment wrt _onScroll? Both this method and that one call setState with a new value for scrollX from my read. Does the comment refer to it not being triggered by a scrollbar drag event? How does that come into play?

Copy link
Contributor Author

@sergek sergek Dec 1, 2017

Choose a reason for hiding this comment

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

After reading it again I think you are absolutely right - there is the same thing going on in both methods.
I've updated the pr, but right now I can't test if this change has any side effects on complex table layouts.
Will check it out on Monday.

Copy link
Member

Choose a reason for hiding this comment

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

This should be safe. There's a small issue that the scrollbar position will be out of sync from the grid scroll position by a fraction of a pixel. Since we sync the scrollbar & grid with absolute positions rather than deltas we shouldn't get any drift though.

I'll give this a once over to ensure there's no weird performance issue if they get out of sync and try setting each other.

Copy link
Member

Choose a reason for hiding this comment

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

Checked and this doesn't cause render loops. If scrollbar is a fraction, then the main grid handles and re-renders it as a non fraction and we're back on track.

I think this is good to merge. any final concerns from your end before I merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works well in my environment.
I hope this is a relatively temporary measure and the gpu text rendering will improve in browsers over time.

@@ -1426,10 +1426,13 @@ var FixedDataTable = createReactClass({
if (!this._isScrolling) {
this._didScrollStart();
}

var roundedScrollPos = Math.round(scrollPos);
Copy link
Member

Choose a reason for hiding this comment

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

Checked and this doesn't cause render loops. If scrollbar is a fraction, then the main grid handles and re-renders it as a non fraction and we're back on track.

I think this is good to merge. any final concerns from your end before I merge?

@wcjordan wcjordan merged commit e8f5a72 into schrodinger:master Dec 6, 2017
@wcjordan
Copy link
Member

wcjordan commented Dec 6, 2017

Released w/ 0.8.7

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