0

I have an angular app with ng-infinite scroll. The problem are:

  • when I am in the middle in the page the callback that loads new content is triggered. And when it gets triggered, it shifts
  • when elements are added to the page and when the end is reached, the scroll keeps at being at the end even though new content was added (whereas the new content should appear after the old elements, and the user should have to scroll to see it)
  • when I click a link and go to the next page, the zoom isn't reset as it should

Here is a screencast: https://imgur.com/KMaCLuQ

Now guys, this is a part of the code (the view that contains post list)

 <div infinite-scroll="loadMorePosts()" infinite-scroll-distance="0">


    <md-card ng-repeat="post in posts">
      <h5 ng-bind-html="post.title"></h5>
      <p ng-bind-html="post.body">
      </p>
    </md-card>
  <div layout="horizontal" layout-align="center">


    <md-progress-circular mode="indeterminate" ng-if="more"></md-progress-circular>

  </div>


</div>

If you want more, feel free to check source code

Vinz243
  • 8,090
  • 9
  • 35
  • 74

1 Answers1

1

I've been using ngInfiniteScroll for quite a while and it works fine with me.

I'm pretty sure that there is something wrong with your code.

Make sure that your update function is called only once by using some kind of lock system. Here is an example:

if ($scope.loaderBusy) {
  return;
}

$scope.loaderBusy = true;

User
.getList()
.then(function(response) {
  $scope.userList = response;
})
.finally(function() {
  $scope.loaderBusy = false;
});

Also the attribute infinite-scroll-distance="0" is not necessary.

Guilhem Soulas
  • 1,905
  • 2
  • 18
  • 28
  • Thank you very much. Is is more stable now. How do I reset scroll when the state is changed (I am using ui-router) and avoid that when the bottom is reached and new content added it stays in the bottom? – Vinz243 Oct 18 '14 at 15:58
  • You can achieve all this by adding those behaviours in your code... There are so many ways: Initialising your list in the UI router resolve section or simply in the controller, adding a reset boolean in your service etc. For the second part of your question, it is normal that the new content is added below your screen and you need to scroll down. Note: All these additions go way beyond the initial question! – Guilhem Soulas Oct 19 '14 at 21:11