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

Do not handle onLaneScroll after the last page was loaded #526

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions src/controllers/Lane.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ class Lane extends Component {
currentPage: this.props.currentPage,
addCardMode: false,
collapsed: false,
isDraggingOver: false
isDraggingOver: false,
lastPage: false
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have currentPage as number. Probable it will be better to rename this prop to isPageLast or to give total pages count in pros like 'totalPages'

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it will be better to rename to isPageLast. Moreover you do not have to extend your API handle onLaneScroll by new 'totalPages' after upgrade.

}

handleScroll = evt => {
const node = evt.target
const elemScrollPosition = node.scrollHeight - node.scrollTop - node.clientHeight
const {onLaneScroll} = this.props
// In some browsers and/or screen sizes a decimal rest value between 0 and 1 exists, so it should be checked on < 1 instead of < 0
if (elemScrollPosition < 1 && onLaneScroll && !this.state.loading) {
if (elemScrollPosition < 1 && onLaneScroll && !this.state.loading && !this.state.lastPage) {
const {currentPage} = this.state
this.setState({loading: true})
const nextPage = currentPage + 1
Expand All @@ -38,6 +39,8 @@ class Lane extends Component {
newCards: moreCards,
nextPage: nextPage
})
} else {
this.setState({lastPage: true});
}
this.setState({loading: false})
})
Expand Down