"use strict"; (function () { 'use strict'; angular.module('myitsmApp') .directive('infinityScroll', function () { return { restrict: 'A', replace: true, scope: { scrollHandler: '&infinityScroll' }, link: function ($scope, iElement) { function onScroll() { //note: https://github.com/angular-ui/ui-grid/issues/3915 // Mac (expecially when using touchpad) does scroll with step 1, and having step 10 cases calling // a callback even when scrolling top. var threshold = navigator.platform.indexOf('Mac') > -1 ? 0 : 10; if (iElement[0].scrollHeight <= (iElement.scrollTop() + iElement.outerHeight() + threshold)) { $scope.scrollHandler(); } } iElement .off('scroll') .on('scroll', onScroll); $scope.$on('$destroy', function () { iElement.off('scroll', onScroll); }); } }; }); }());