Fix incorrect behaviour in PDFThumbnailViewer.scrollThumbnailIntoView for multiple columns of thumbnails

If the sidebar is resized such that the thumbnails are displayed in multiple columns, then scrolling the currently active thumbnail into view doesn't work correctly in some cases.
The reason is that the code in `PDFThumbnailViewer.scrollThumbnailIntoView` implicitly assumes that the thumbnails will be present in just *one* column. Since that may no longer be the case, it's not sufficient to simply check if the thumbnail is visible. Instead we must explicitly check that *all*, i.e. 100 percent, of the thumbnail is already visible, and otherwise scroll it into view.
This commit is contained in:
Jonas Jenwald 2017-11-11 22:57:59 +01:00
parent 0052dc2b0d
commit 614ab4ef2c

View File

@ -84,7 +84,20 @@ class PDFThumbnailViewer {
let first = visibleThumbs.first.id;
// Account for only one thumbnail being visible.
let last = (numVisibleThumbs > 1 ? visibleThumbs.last.id : first);
let shouldScroll = false;
if (page <= first || page >= last) {
shouldScroll = true;
} else {
visibleThumbs.views.some(function(view) {
if (view.id !== page) {
return false;
}
shouldScroll = view.percent < 100;
return true;
});
}
if (shouldScroll) {
scrollIntoView(thumbnail, { top: THUMBNAIL_SCROLL_MARGIN, });
}
}