angular upward infinite scroll directive

angular upward-infinite-scroll

upward-infinite-scroll

Created by Nicolas Peters

Demo

angular.module('myapp').controller('UpwardsScroll', function($scope, $http) {
var counter = 1;
var limit = 50;
$scope.items = [];
$scope.LoadMore = function() {
for (var i = 0; i < limit; i++) { $scope.items.unshift( { text: counter } ); counter++; } }; $scope.LoadMore(); }); angular.module('myapp').directive('upwardsScoll', function ($timeout) { return { link: function (scope, elem, attr, ctrl) { var raw = elem[0]; elem.bind('scroll', function() { if(raw.scrollTop <= 0) { var sh = raw.scrollHeight; scope.$apply(attr.upwardsScoll); $timeout(function() { elem.animate({ scrollTop: raw.scrollHeight - sh },500); }, 0); } }); //scroll to bottom $timeout(function() { scope.$apply(function () { elem.scrollTop( raw.scrollHeight ); }); }, 0); } } });

Javscript

Javascript plugin

Angular-js