From 26c733e237ad7da90a7a2f83fc0d51d2f8d69015 Mon Sep 17 00:00:00 2001 From: John McLear Date: Thu, 7 Jan 2021 20:19:36 +0000 Subject: [PATCH] better handling of line heights --- src/static/js/scroll.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/static/js/scroll.js b/src/static/js/scroll.js index 31a9dccd2..34d9868a6 100644 --- a/src/static/js/scroll.js +++ b/src/static/js/scroll.js @@ -356,13 +356,14 @@ Scroll.prototype.movePage = function (direction) { const buffer = 25; // we need to remember that lineoffset needs to be removed too.. let offset = linePosition.bottom - viewport.top; + let lineHeight = linePosition.top - linePosition.bottom; let pixelsToScroll = viewport.top - viewport.bottom + offset; if (direction === 'up') { // buffer pixels unscrolled our safety net here. You can't use the current or previous // line height because it might be a very long line.. - pixelsToScroll = -Math.abs(pixelsToScroll + buffer/2); + pixelsToScroll = -Math.abs(pixelsToScroll - lineHeight); } else { - pixelsToScroll = Math.abs(pixelsToScroll + buffer/2); + pixelsToScroll = Math.abs(pixelsToScroll - lineHeight); } this.outerWin.scrollBy(0, pixelsToScroll);