1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-02 00:42:45 +01:00

This fixes scrolling not being pinned on Firefox

This commit is contained in:
gorhill 2015-01-26 14:07:55 -05:00
parent cd597f9d4a
commit 44fa4d72d0

View File

@ -125,6 +125,10 @@ var renderLogEntry = function(entry) {
/******************************************************************************/ /******************************************************************************/
var renderLogBuffer = function(buffer) { var renderLogBuffer = function(buffer) {
if ( buffer.length === 0 ) {
return;
}
// Preserve scroll position // Preserve scroll position
var height = tbody.offsetHeight; var height = tbody.offsetHeight;
@ -132,8 +136,26 @@ var renderLogBuffer = function(buffer) {
for ( var i = 0; i < n; i++ ) { for ( var i = 0; i < n; i++ ) {
renderLogEntry(buffer[i]); renderLogEntry(buffer[i]);
} }
var yDelta = tbody.offsetHeight - height;
if ( yDelta === 0 ) {
return;
}
// Chromium:
// body.scrollTop = good value
// body.parentNode.scrollTop = 0
if ( body.scrollTop !== 0 ) { if ( body.scrollTop !== 0 ) {
body.scrollTop += tbody.offsetHeight - height; body.scrollTop += yDelta;
return;
}
// Firefox:
// body.scrollTop = 0
// body.parentNode.scrollTop = good value
var parentNode = body.parentNode;
if ( parentNode && parentNode.scrollTop !== 0 ) {
parentNode.scrollTop += yDelta;
} }
}; };