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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I also just found this, maybe better for what you want to do: nicolaspeters.wordpress.com/2014/08/01/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.