Skip to content

Instantly share code, notes, and snippets.

@jmaicher
Created April 3, 2016 14:15
Show Gist options
  • Save jmaicher/3e97f93b44fda413ff1dea2babfea26a to your computer and use it in GitHub Desktop.
Save jmaicher/3e97f93b44fda413ff1dea2babfea26a to your computer and use it in GitHub Desktop.
endless container
export default function endlessContainer() {
'ngInject';
return {
restrict: 'A',
scope: {
'endlessContainer': '&'
},
link: function (scope, element, attrs) {
element.bind('scroll', function() {
let height = this.scrollHeight - element.height();
let scrollTop = element.scrollTop();
let isScrolledToEnd = (scrollTop >= height);
if(isScrolledToEnd) {
scope.$evalAsync(scope.endlessContainer);
}
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment