Revert "[DISCUSS] Remove "scroll to readmarker" functionality"
This commit is contained in:
parent
773a80b40c
commit
c4d8a4fe10
|
@ -505,8 +505,10 @@ weechat.factory('connection',
|
||||||
}
|
}
|
||||||
$rootScope.loadingLines = false;
|
$rootScope.loadingLines = false;
|
||||||
|
|
||||||
// "Scroll" to maintain position
|
// Only scroll to read marker if we didn't have all unread lines previously, but have them now
|
||||||
$rootScope.scrollWithBuffer(/* moreLines */ true);
|
var scrollToReadmarker = !hadAllUnreadLines && buffer.lastSeen >= 0;
|
||||||
|
// Scroll to correct position
|
||||||
|
$rootScope.scrollWithBuffer(scrollToReadmarker, true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
connection.requestNicklist(ab.id, function() {
|
connection.requestNicklist(ab.id, function() {
|
||||||
$scope.showNicklist = $scope.updateShowNicklist();
|
$scope.showNicklist = $scope.updateShowNicklist();
|
||||||
// Scroll after nicklist has been loaded, as it may break long lines
|
// Scroll after nicklist has been loaded, as it may break long lines
|
||||||
$rootScope.scrollWithBuffer();
|
$rootScope.scrollWithBuffer(true);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Check if we should show nicklist or not
|
// Check if we should show nicklist or not
|
||||||
|
@ -195,7 +195,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$rootScope.updateBufferBottom(true);
|
$rootScope.updateBufferBottom(true);
|
||||||
$rootScope.scrollWithBuffer();
|
$rootScope.scrollWithBuffer(true);
|
||||||
bl.onscroll = _.debounce(function() {
|
bl.onscroll = _.debounce(function() {
|
||||||
$rootScope.updateBufferBottom();
|
$rootScope.updateBufferBottom();
|
||||||
}, 80);
|
}, 80);
|
||||||
|
@ -211,7 +211,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
});
|
});
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$rootScope.scrollWithBuffer();
|
$rootScope.scrollWithBuffer(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Clear search term on buffer change
|
// Clear search term on buffer change
|
||||||
|
@ -584,7 +584,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
}
|
}
|
||||||
$rootScope.bufferBottom = eob.offsetTop <= bl.scrollTop + bl.clientHeight;
|
$rootScope.bufferBottom = eob.offsetTop <= bl.scrollTop + bl.clientHeight;
|
||||||
};
|
};
|
||||||
$rootScope.scrollWithBuffer = function(moreLines) {
|
$rootScope.scrollWithBuffer = function(scrollToReadmarker, moreLines) {
|
||||||
// First, get scrolling status *before* modification
|
// First, get scrolling status *before* modification
|
||||||
// This is required to determine where we were in the buffer pre-change
|
// This is required to determine where we were in the buffer pre-change
|
||||||
var bl = document.getElementById('bufferlines');
|
var bl = document.getElementById('bufferlines');
|
||||||
|
@ -595,9 +595,14 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
// Determine if we want to scroll at all
|
// Determine if we want to scroll at all
|
||||||
// Give the check 3 pixels of slack so you don't have to hit
|
// Give the check 3 pixels of slack so you don't have to hit
|
||||||
// the exact spot. This fixes a bug in some browsers
|
// the exact spot. This fixes a bug in some browsers
|
||||||
if ((moreLines && sTop < sVal) || (Math.abs(sTop - sVal) < 3)) {
|
if (((scrollToReadmarker || moreLines) && sTop < sVal) || (Math.abs(sTop - sVal) < 3)) {
|
||||||
if (moreLines) {
|
var readmarker = document.querySelector(".readmarker");
|
||||||
// We fetched more lines, keep the scroll position constant
|
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
|
||||||
bl.scrollTop = bl.scrollHeight - bl.clientHeight - sVal;
|
bl.scrollTop = bl.scrollHeight - bl.clientHeight - sVal;
|
||||||
} else {
|
} else {
|
||||||
// New message, scroll with buffer (i.e. to bottom)
|
// New message, scroll with buffer (i.e. to bottom)
|
||||||
|
|
Loading…
Reference in New Issue