better handling of line heights

page-down-up-bugfix
John McLear 2021-01-07 20:19:36 +00:00
parent 2fff1c473f
commit 26c733e237
1 changed files with 3 additions and 2 deletions

View File

@ -356,13 +356,14 @@ Scroll.prototype.movePage = function (direction) {
const buffer = 25; const buffer = 25;
// we need to remember that lineoffset needs to be removed too.. // we need to remember that lineoffset needs to be removed too..
let offset = linePosition.bottom - viewport.top; let offset = linePosition.bottom - viewport.top;
let lineHeight = linePosition.top - linePosition.bottom;
let pixelsToScroll = viewport.top - viewport.bottom + offset; let pixelsToScroll = viewport.top - viewport.bottom + offset;
if (direction === 'up') { if (direction === 'up') {
// buffer pixels unscrolled our safety net here. You can't use the current or previous // 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.. // line height because it might be a very long line..
pixelsToScroll = -Math.abs(pixelsToScroll + buffer/2); pixelsToScroll = -Math.abs(pixelsToScroll - lineHeight);
} else { } else {
pixelsToScroll = Math.abs(pixelsToScroll + buffer/2); pixelsToScroll = Math.abs(pixelsToScroll - lineHeight);
} }
this.outerWin.scrollBy(0, pixelsToScroll); this.outerWin.scrollBy(0, pixelsToScroll);