2

I'm using ngInfiniteScroll, but the default action is to load more items, when the bottom is reached, just like facebook timeline, but I need the opposite, I need to load the items, when the top is reached.

Is there a way to do that with ngInfiniteScroll or with another way?

Thanks a lot.

Matheus Lima
  • 2,103
  • 3
  • 31
  • 49

1 Answers1

1

I don't know if it would be possible with nginfinitescroll, but i had to recently write my own. This code will load more data (10 at a time) into my scope.

scrolled

app.directive('scrolled', function () {

    return function (scope, elm, attr) {
        var raw = elm[0];
        var funCheckBounds = function (evt) {
            var rectObject = raw.getBoundingClientRect();
                //rectObject.bottom <= window.innerHeight for scroll to bottom
                if (rectObject.top >= window.innerHeight) {
                    scope.$apply(attr.scrolled);
                }
           };
       angular.element(window).bind('scroll load', funCheckBounds);
    };
});

And of course put scrolled in your template.

Aero204
  • 99
  • 10
  • I also just found this, maybe better for what you want to do: http://nicolaspeters.wordpress.com/2014/08/01/angularjs-upwards-infinite-scroll/ – Aero204 Aug 11 '14 at 16:31