Skip to content

Instantly share code, notes, and snippets.

@jmaicher
Created April 3, 2016 14:15

Revisions

  1. Julian Maicher created this gist Apr 3, 2016.
    21 changes: 21 additions & 0 deletions endless.container.directive.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    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);
    }
    });
    }
    }
    }