Implement infinite scrolling

I't not perfect but it's a start.
This commit is contained in:
Tor Hveem 2015-12-19 15:44:34 +01:00
commit df36d56fa7
3 changed files with 34 additions and 1 deletions

View file

@ -539,6 +539,17 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
return connection.fetchMoreLines(numLines);
};
$scope.infiniteScroll = function() {
// Check if we are already fetching
if ($rootScope.loadingLines) {
return;
}
var buffer = models.getActiveBuffer();
if (!buffer.allLinesFetched) {
$scope.fetchMoreLines();
}
};
$rootScope.updateBufferBottom = function(bottom) {
var eob = document.getElementById("end-of-buffer");
var bl = document.getElementById('bufferlines');

View file

@ -0,0 +1,21 @@
(function() {
'use strict';
var weechat = angular.module('weechat');
weechat.directive('whenScrolled', function() {
return function(scope, elm, attr) {
var raw = elm[0];
var fun = function() {
if (raw.scrollTop === 0) {
scope.$apply(attr.whenScrolled);
}
};
elm.bind('scroll', function() {
_.debounce(fun, 200)();
});
};
});
})();