Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Loading items on container height dynamically changed #192

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bsalex
Copy link

@bsalex bsalex commented Oct 20, 2016

In my case, the container size is not fixed and is changed according to page size (flexible markup).

The problem appears when the page is resized without scroll events on react-infinite component, it leads to empty space below previously loaded requests. The PR fixes it.

The PR includes tests.

@coveralls
Copy link

coveralls commented Oct 20, 2016

Coverage Status

Coverage increased (+0.2%) to 94.118% when pulling 9dc4d91 on bsalex:master into e453e65 on seatgeek:master.

@bsalex
Copy link
Author

bsalex commented Nov 7, 2016

Ping

@bsalex
Copy link
Author

bsalex commented Jan 25, 2017

Do you have any objections?

@@ -305,6 +305,15 @@ var Infinite = React.createClass({
if (isMissingVisibleRows) {
this.onInfiniteLoad();
}

if (this.props.containerHeight !== prevProps.containerHeight) {
Copy link

Choose a reason for hiding this comment

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

⚠️ containerHeight is computed in generateComputedProps so you can't get the previous value by this way

Copy link
Author

Choose a reason for hiding this comment

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

Fixed


if (this.props.containerHeight !== prevProps.containerHeight) {
const scrollTop = this.utils.getScrollTop();
const newApertureState = infiniteHelpers.recomputeApertureStateFromOptionsAndScrollTop(this.state, scrollTop);
Copy link

Choose a reason for hiding this comment

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

You may rely on handleScroll for the rest ?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, thanks, it is much simpler now

@@ -448,6 +448,37 @@ describe("React Infinite's Infinite Scroll Capabilities", function() {
expect(infiniteSpy).not.toHaveBeenCalled();
});

it('triggers the onInfiniteLoad function when containerHeight changes', function() {
Copy link

@DevSide DevSide May 11, 2017

Choose a reason for hiding this comment

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

you may provide the case where useWindowAsScrollContainer is true so when containerHeight changes, onInfiniteLoad is not called

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 94.068% when pulling 2d66c29 on bsalex:master into 94dc599 on seatgeek:master.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants