Basic pagination working

This commit is contained in:
Edin Dazdarevic
2017-04-07 04:50:46 +02:00
parent 5515774d17
commit 0fcee4a741
6 changed files with 90 additions and 85 deletions

View File

@@ -15,12 +15,17 @@ export default class Listings extends React.Component {
//console.log('node.parentNode.scrollTop', node.scrollTop);
//console.log('node.parentNode.clientHeight', node.clientHeight);
if (this.props && this.props.loadingMore) {
console.log('still loading!');
return;
}
console.log('scrolling', node.scrollTop, node.scrollHeight, offset);
if (offset < 50) {
console.log('load more');
this.removeScrollListener();
//this.removeScrollListener();
this.props.dispatch({type: 'LOAD_MORE_LISTINGS'});
}
}
@@ -46,15 +51,13 @@ export default class Listings extends React.Component {
componentDidUpdate (prevProps) {
console.log('RECEIVING PROPS: ', prevProps, 'new are', this.props);
//setTimeout(() => {
//this.attachScrollListener();
//}, 1000);
if (this.props.loadingMore != null) {
if (!this.props.loadingMore && prevProps.loadingMore) {
this.attachScrollListener();
console.log('ATTACHING AGAIN', this);
}
}
//if (this.props.loadingMore != null) {
//if (!this.props.loadingMore && prevProps.loadingMore) {
//this.attachScrollListener();
//console.log('ATTACHING AGAIN', this);
//}
//}
}
renderListings () {
@@ -131,7 +134,7 @@ export default class Listings extends React.Component {
render () {
const {listings = (new Map())} = this.props;
const {listings = (new Map()), totalCount} = this.props;
return (
<div ref="listings" className="listings">
@@ -145,7 +148,7 @@ export default class Listings extends React.Component {
</div>
</div>
<div className="listings-count">
{listings.size} rezultata
{totalCount} rezultata
</div>
</div>