Whenever I scroll the page, my function pushes items to an array. However, I am facing an issue where the pushed items are repeating instead of adding new ones.
Solution Attempt
onScroll(): void {
console.log('scrolled');
var i,j,newArray,chunk = 10;
for (i=0,j=this.listOfData.length; i<j; i+=chunk) {
newArray = this.listOfData.slice(i,i+chunk);
this.results = this.results.concat(newArray);
}
}
The this.listOfData
array contains 19 items but only shows 19 to 10 in a loop, repeating, while items from 9 to 1 never appear.
Original code source
Any suggestions on how to fix this issue?
Update
If it's unclear, I have created a short video demonstrating the problem Watch here