mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 11:26:09 -04:00
Added infinite scrolling. It's sliiiightly buggy in that it jumps down the list a bit, but it is overall working pretty well. Added ng-infinite-scroll-matrix.js and jquery-1.8.3 as deps.
This commit is contained in:
parent
02e45da895
commit
5b817ecd44
7 changed files with 115 additions and 9 deletions
2
webclient/js/jquery-1.8.3.min.js
vendored
Normal file
2
webclient/js/jquery-1.8.3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
63
webclient/js/ng-infinite-scroll-matrix.js
Normal file
63
webclient/js/ng-infinite-scroll-matrix.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* ng-infinite-scroll - v1.0.0 - 2013-02-23
|
||||
Matrix: Modified to support scrolling UP to get infinite loading and to listen
|
||||
to scroll events on the PARENT element, not the window.
|
||||
*/
|
||||
var mod;
|
||||
|
||||
mod = angular.module('infinite-scroll', []);
|
||||
|
||||
mod.directive('infiniteScroll', [
|
||||
'$rootScope', '$window', '$timeout', function($rootScope, $window, $timeout) {
|
||||
return {
|
||||
link: function(scope, elem, attrs) {
|
||||
var checkWhenEnabled, handler, scrollDistance, scrollEnabled;
|
||||
$window = angular.element($window);
|
||||
scrollDistance = 0;
|
||||
if (attrs.infiniteScrollDistance != null) {
|
||||
scope.$watch(attrs.infiniteScrollDistance, function(value) {
|
||||
return scrollDistance = parseInt(value, 10);
|
||||
});
|
||||
}
|
||||
scrollEnabled = true;
|
||||
checkWhenEnabled = false;
|
||||
if (attrs.infiniteScrollDisabled != null) {
|
||||
scope.$watch(attrs.infiniteScrollDisabled, function(value) {
|
||||
scrollEnabled = !value;
|
||||
if (scrollEnabled && checkWhenEnabled) {
|
||||
checkWhenEnabled = false;
|
||||
return handler();
|
||||
}
|
||||
});
|
||||
}
|
||||
handler = function() {
|
||||
var elementTop, remaining, shouldScroll, windowTop;
|
||||
windowTop = 0;
|
||||
elementTop = elem.offset().top;
|
||||
shouldScroll = elementTop >= 0; // top of list is at the top of the window or further down the page
|
||||
if (shouldScroll && scrollEnabled) {
|
||||
if ($rootScope.$$phase) {
|
||||
return scope.$eval(attrs.infiniteScroll);
|
||||
} else {
|
||||
return scope.$apply(attrs.infiniteScroll);
|
||||
}
|
||||
} else if (shouldScroll) {
|
||||
return checkWhenEnabled = true;
|
||||
}
|
||||
};
|
||||
elem.parent().on('scroll', handler);
|
||||
scope.$on('$destroy', function() {
|
||||
return elem.parent().off('scroll', handler);
|
||||
});
|
||||
return $timeout((function() {
|
||||
if (attrs.infiniteScrollImmediateCheck) {
|
||||
if (scope.$eval(attrs.infiniteScrollImmediateCheck)) {
|
||||
return handler();
|
||||
}
|
||||
} else {
|
||||
return handler();
|
||||
}
|
||||
}), 0);
|
||||
}
|
||||
};
|
||||
}
|
||||
]);
|
Loading…
Add table
Add a link
Reference in a new issue