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

allow for other elements to be above a windowed infinite list #260

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions __tests__/infinite_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,14 @@ describe('React Infinite when the window is used as the Container', function() {

return listenerTriggered.then(listener => {
window.pageYOffset = 1500;
rootNode.node.scrollable.getBoundingClientRect = () => ({
width: 1440,
height: 4000,
top: -1500,
left: 0,
right: 1440,
bottom: 2500
});
listener();
expect(mountToJson(rootNode)).toMatchSnapshot();
window.addEventListener = oldAdd;
Expand Down
10 changes: 9 additions & 1 deletion src/react-infinite.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,15 @@ class Infinite extends React.Component<
window.removeEventListener('scroll', this.infiniteHandleScroll);
};
utilities.nodeScrollListener = () => {};
utilities.getScrollTop = () => window.pageYOffset;
utilities.getScrollTop = () => {
if (this.computedProps && this.computedProps.displayBottomUpwards) {
return window.pageYOffset;
}

return this.scrollable
? Math.max(0, -this.scrollable.getBoundingClientRect().top)
: 0;
};
utilities.setScrollTop = top => {
window.scroll(window.pageXOffset, top);
};
Expand Down