I've built an app using React and Redux which calls an api from the backend and renders a list of items. There's infinite scrolling pagination on this list. It looks something like this.
I'm using this app to open in an Android app webview but that's not the problem. The problem is that when there's only one page pagination, its performance is fine while scrolling but as soon as it reaches the bottom of the page and triggers an event of api call to fetch the next page result from the backend, I observe a very bad jank on scrolling. Not only that, the page moves to a very less distance on scrolling, I have to move my finger twice or thrice to scroll upwards or downwards.
I have tried running the redux functionality inside web worker since single UI thread from everything might have been causing problem. But, the results are not statisfying even after that.
What can I do to make the scroll good and move to a good intended distance when I move webpage on touch.
Here's some code for the same.
componentDidMount(){
if(this.showTabs(this.props.location.query.uri)){
this.props.setCurrentDealListingType('online');
this.fetchOnlineDeals();
} else {
this.props.setCurrentDealListingType('deals');
this.fetchDeals();
}
var self = this;
scrollHandler = function (event) {
if (document.body.scrollHeight ===
document.body.scrollTop +
window.innerHeight) {
self.fetchPaginatedResult();
}
}
document.addEventListener('scroll', scrollHandler);
}
componentWillUnmount(){
document.removeEventListener('scroll', scrollHandler);
}