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

Enable autoWidth on Grid in combination with horizontal WindowScroller #644

Merged
merged 2 commits into from
Apr 5, 2017

Conversation

maxnowack
Copy link
Contributor

Adds the ability to use WindowScroller to detect horizontal scrolling. This allows the usage of autoWidth on the Grid component.
I'm not sure why these two cases weren't already implemented.

@maxnowack maxnowack changed the title Enable autoWidth on Grid in combination with WindowScroller Enable autoWidth on Grid in combination with horizontal WindowScroller Apr 5, 2017
@bvaughn
Copy link
Owner

bvaughn commented Apr 5, 2017

I'm not sure why these two cases weren't already implemented.

Because no one has needed it before now and it takes time and effort to implement things. 😛 Plus once a thing has been implemented, I'm stuck supporting it forever and people who use react-virtualized have to accept a slightly larger payload size and potentially slightly slower runtime.

I'm not really convinced this is a useful feature. Why would you want a Grid to have a width wider than the viewport? Vertical "auto" is useful for building UIs with fixed headers but I don't think it's common for the same type of UIs to be horizontal.

@bvaughn
Copy link
Owner

bvaughn commented Apr 5, 2017

To be clear~ I appreciate the PR! 😄 (thank you!)

I'm just not sure about this feature.

@maxnowack
Copy link
Contributor Author

This wasn't meant as a reproach 😉
I was looking at the code, saw all the height stuff and wondered about where the width is.

I'm building a kanban/trello like application (teamgridapp.com). At this time, I'm kicking out our legacy UI framework and rewrite the views in React. Our main view shows all team members in horizontal aligned lists, which I want to virtualize. There're some reasons (styling, sortable, etc.), why these lists don't have a own scrollable div and use one of the parents for scrolling instead.
I've tried to implement virtualize using my PR and it works very well.

@bvaughn bvaughn merged commit 627c45f into bvaughn:master Apr 5, 2017
@bvaughn
Copy link
Owner

bvaughn commented Apr 5, 2017

No worries 😄 Sorry if my reaction seemed defensive. Harder to communicate when sleepy.

Copy link
Owner

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

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

I made some comments for small things on the PR, but I went ahead and made those changes myself while reviewing to reduce the number of back-and-forth cycles.

This will go out with the next release, 9.6.0

Thanks for the contribution and the discussion.

const grid = render(getMarkup(props))
const rendered = findDOMNode(grid)
expect(rendered.querySelector('.ReactVirtualized__Grid__innerScrollContainer').style.width).toEqual('2500px') // 50 columns * 50px columnWidth
expect(grid._rowSizeAndPositionManager.getTotalSize()).toEqual(2000)
Copy link
Owner

Choose a reason for hiding this comment

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

Should be checking total column size:

expect(grid._columnSizeAndPositionManager.getTotalSize()).toEqual(2500)

I can patch this.

)
) {
this._scrollingContainer.scrollLeft = scrollLeft
}
Copy link
Owner

Choose a reason for hiding this comment

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

I think you meant to add this conditional above. As it is, it actually checksscrollLeft 1 or 2 times.

@@ -1104,6 +1122,9 @@ export default class Grid extends PureComponent {
if (!autoHeight) {
newState.scrollTop = scrollTop
}
if (!autoWidth) {
newState.scrollLeft = scrollLeft
Copy link
Owner

Choose a reason for hiding this comment

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

Same type of comment here. scrollLeft has already been set above, inline, within newState.


mockGetBoundingClientRectForHeader({
height: 200
height: 200,
width: 200
Copy link
Owner

Choose a reason for hiding this comment

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

I usually like to use different values for width/height or scrollLeft/scrollTop to avoid possibly missing a bug where I transpose the 2 internally.


this.state = {
height,
width,
Copy link
Owner

Choose a reason for hiding this comment

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

state should probably initialize scrollLeft to 0 as well

@bvaughn
Copy link
Owner

bvaughn commented Apr 5, 2017

9.6.0 release just went out with this.

@maxnowack
Copy link
Contributor Author

maxnowack commented Apr 5, 2017

Wow, this was fast! Thank you for applying the changes and for all the great work with this package!
I'm deeply impressed of how you manage your open source projects and how fast you react to pull requests and issues.
Again: Thank you!

@maxnowack maxnowack deleted the horizontal-grid branch April 5, 2017 18:25
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.

2 participants