From 2c779a8fbec72d0810319ff0075e55bc4c4b38e6 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 25 Oct 2021 14:20:24 +0200 Subject: [PATCH] [Regression] Prevent breaking errors when opening a new document in the GENERIC viewer (PR 14158 follow-up) In the GENERIC viewer, e.g. when dragging-and-dropping a new PDF document which automatically opens the outline, there can now be breaking errors in the `{BaseViewer, PDFThumbnailViewer}.#getScrollAhead` methods since there's no visible pages/thumbs during loading; sorry about the breakage! --- web/base_viewer.js | 6 +++--- web/pdf_thumbnail_viewer.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/web/base_viewer.js b/web/base_viewer.js index fdfb7857e..6692ede0e 100644 --- a/web/base_viewer.js +++ b/web/base_viewer.js @@ -1361,10 +1361,10 @@ class BaseViewer { return promise; } - #getScrollAhead(views) { - if (views.first.id === 1) { + #getScrollAhead(visible) { + if (visible.first?.id === 1) { return true; - } else if (views.last.id === this.pagesCount) { + } else if (visible.last?.id === this.pagesCount) { return false; } switch (this._scrollMode) { diff --git a/web/pdf_thumbnail_viewer.js b/web/pdf_thumbnail_viewer.js index 350b1a820..d25e8e60d 100644 --- a/web/pdf_thumbnail_viewer.js +++ b/web/pdf_thumbnail_viewer.js @@ -295,10 +295,10 @@ class PDFThumbnailViewer { return promise; } - #getScrollAhead(views) { - if (views.first.id === 1) { + #getScrollAhead(visible) { + if (visible.first?.id === 1) { return true; - } else if (views.last.id === this._thumbnails.length) { + } else if (visible.last?.id === this._thumbnails.length) { return false; } return this.scroll.down;