Remove "scroll to readmarker" functionality

It's irritating. Fixes #899
This commit is contained in:
Lorenz Hübschle-Schneider 2017-03-01 14:21:46 +01:00
parent 90ce0345a1
commit 1fa6462bca
2 changed files with 9 additions and 16 deletions

View file

@ -503,10 +503,8 @@ weechat.factory('connection',
}
$rootScope.loadingLines = false;
// Only scroll to read marker if we didn't have all unread lines previously, but have them now
var scrollToReadmarker = !hadAllUnreadLines && buffer.lastSeen >= 0;
// Scroll to correct position
$rootScope.scrollWithBuffer(scrollToReadmarker, true);
// "Scroll" to maintain position
$rootScope.scrollWithBuffer(/* moreLines */ true);
});
};

View file

@ -154,7 +154,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
connection.requestNicklist(ab.id, function() {
$scope.showNicklist = $scope.updateShowNicklist();
// Scroll after nicklist has been loaded, as it may break long lines
$rootScope.scrollWithBuffer(true);
$rootScope.scrollWithBuffer();
});
} else {
// Check if we should show nicklist or not
@ -187,7 +187,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
}
};
$rootScope.updateBufferBottom(true);
$rootScope.scrollWithBuffer(true);
$rootScope.scrollWithBuffer();
bl.onscroll = _.debounce(function() {
$rootScope.updateBufferBottom();
}, 80);
@ -203,7 +203,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
});
$timeout(function() {
$rootScope.scrollWithBuffer(true);
$rootScope.scrollWithBuffer();
});
// Clear search term on buffer change
@ -546,7 +546,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
}
$rootScope.bufferBottom = eob.offsetTop <= bl.scrollTop + bl.clientHeight;
};
$rootScope.scrollWithBuffer = function(scrollToReadmarker, moreLines) {
$rootScope.scrollWithBuffer = function(moreLines) {
// First, get scrolling status *before* modification
// This is required to determine where we were in the buffer pre-change
var bl = document.getElementById('bufferlines');
@ -557,14 +557,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// Determine if we want to scroll at all
// Give the check 3 pixels of slack so you don't have to hit
// the exact spot. This fixes a bug in some browsers
if (((scrollToReadmarker || moreLines) && sTop < sVal) || (Math.abs(sTop - sVal) < 3)) {
var readmarker = document.querySelector(".readmarker");
if (scrollToReadmarker && readmarker) {
// Switching channels, scroll to read marker
bl.scrollTop = readmarker.offsetTop - readmarker.parentElement.scrollHeight + readmarker.scrollHeight;
} else if (moreLines) {
// We fetched more lines but the read marker is still out of view
// Keep the scroll position constant
if ((moreLines && sTop < sVal) || (Math.abs(sTop - sVal) < 3)) {
if (moreLines) {
// We fetched more lines, keep the scroll position constant
bl.scrollTop = bl.scrollHeight - bl.clientHeight - sVal;
} else {
// New message, scroll with buffer (i.e. to bottom)