flexyford / impagination

A lazy data layer for your paged records
102 stars 7 forks source link

Can't get Infinite scroll to work seems to stop at loadhorizon value? #39

Open mattdwardle opened 7 years ago

mattdwardle commented 7 years ago

Here is a snippet from my setupImpagination function. This stopped when the page offset was 14. Thanks

    setupImpagination() {
        let _this = this;
        let dataset = new Dataset({
            pageSize: 4,
            loadHorizon: 10,
            // pageOffset: this.state.pageOffset,
            // Anytime there's a new state emitted, we want to set that on
            // the componets local state.
            observe: (datasetState) => {
                this.setState({ datasetState });
            },

            // Where to fetch the data from.
            fetch(pageOffset, pageSize, stats) {
                console.log('page offset - ' + pageOffset);
                console.log('page size - ' + pageSize);
                var URL = 'https://example.com/wp-json/custom/v1/article_video_callback/?page=' + pageOffset + '&per_page=' + pageSize;
                return fetch(URL)
                    .then(response => response.json())
                    .catch((error) => {
                        console.error(error);
                    });
            }
        });

        // Set the readOffset to the first record in the state
        dataset.setReadOffset(0);
        this.setState({ dataset });        
    }
cowboyd commented 6 years ago

@mattdwardle Can you post the content of the console?