Basic pagination working
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user