|
|
@ -758,12 +758,24 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate number of lines to fetch
|
|
|
|
// Calculate number of lines to fetch
|
|
|
|
$scope.lines = function() { |
|
|
|
$scope.calculateNumLines = function() { |
|
|
|
var lineHeight = document.querySelector(".bufferline").clientHeight; |
|
|
|
var lineHeight = document.querySelector(".bufferline").clientHeight; |
|
|
|
// I would have used document.querySelector("#bufferlines").clientHeight and added 5 to the total result, but that provides incorrect values on mobile
|
|
|
|
var areaHeight = document.querySelector("#bufferlines").clientHeight; |
|
|
|
var areaHeight = document.body.clientHeight; |
|
|
|
// Fetch 10 lines more than theoretically needed so that scrolling up will correctly trigger the loading of more lines
|
|
|
|
return Math.ceil(areaHeight/lineHeight); |
|
|
|
// Also, some lines might be hidden, so it's probably better to have a bit of buffer there
|
|
|
|
}(); |
|
|
|
var numLines = Math.ceil(areaHeight/lineHeight + 10); |
|
|
|
|
|
|
|
$scope.lines = numLines; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
$scope.calculateNumLines(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Recalculate number of lines on resize
|
|
|
|
|
|
|
|
window.addEventListener("resize", _.debounce(function() { |
|
|
|
|
|
|
|
// Recalculation fails when not connected
|
|
|
|
|
|
|
|
if ($rootScope.connected) { |
|
|
|
|
|
|
|
$scope.calculateNumLines(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, 100)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$rootScope.loadingLines = false; |
|
|
|
$rootScope.loadingLines = false; |
|
|
|
$scope.fetchMoreLines = function() { |
|
|
|
$scope.fetchMoreLines = function() { |
|
|
|