ApplicationManager and better memory management

This commit is contained in:
Mo Bitar
2020-03-23 19:59:55 -05:00
parent 7dc3dab90b
commit ee7cb1fce6
55 changed files with 36786 additions and 3046 deletions

View File

@@ -1,16 +1,20 @@
/* @ngInject */
export function infiniteScroll($rootScope, $window, $timeout) {
export function infiniteScroll() {
return {
link: function(scope, elem, attrs) {
const offset = parseInt(attrs.threshold) || 0;
const e = elem[0];
elem.on('scroll', function() {
scope.onScroll = () => {
if (
scope.$eval(attrs.canLoad) &&
e.scrollTop + e.offsetHeight >= e.scrollHeight - offset
) {
scope.$apply(attrs.infiniteScroll);
}
};
elem.on('scroll', scope.onScroll);
scope.$on('$destroy', () => {
elem.off('scroll', scope.onScroll);;
});
}
};