From 5ef294b3a757e222b5883ea72b886dae0fffb319 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 5 Apr 2022 13:32:09 +0200 Subject: [PATCH] Remove the `BaseViewer._getCurrentVisiblePage` helper method This method was originally added specifically to work-around bugs/issues related to PresentationMode in Google Chrome. Note that prior to PR 14112 we were using some CSS hacks to only show the current page in PresentationMode, and that could lead to the `getVisibleElements` function not always finding the correct elements. However, after the changes in PR 14112 we're now using the Page-scrolling mode in PresentationMode and consequently there'll only be *a single* page visible at a time. Hence then `BaseViewer._getCurrentVisiblePage` helper method should no longer be needed, and when testing (locally) in Google Chrome everything seems to work correctly now. --- web/base_viewer.js | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/web/base_viewer.js b/web/base_viewer.js index 1f3b82fd0..f055122b2 100644 --- a/web/base_viewer.js +++ b/web/base_viewer.js @@ -1418,37 +1418,7 @@ class BaseViewer { : this.container.scrollHeight > this.container.clientHeight; } - /** - * Helper method for `this._getVisiblePages`. Should only ever be used when - * the viewer can only display a single page at a time, for example: - * - When PresentationMode is active. - */ - _getCurrentVisiblePage() { - if (!this.pagesCount) { - return { views: [] }; - } - const pageView = this._pages[this._currentPageNumber - 1]; - // NOTE: Compute the `x` and `y` properties of the current view, - // since `this._updateLocation` depends of them being available. - const element = pageView.div; - - const view = { - id: pageView.id, - x: element.offsetLeft + element.clientLeft, - y: element.offsetTop + element.clientTop, - view: pageView, - }; - const ids = new Set([pageView.id]); - - return { first: view, last: view, views: [view], ids }; - } - _getVisiblePages() { - if (this.isInPresentationMode) { - // The algorithm in `getVisibleElements` doesn't work in all browsers and - // configurations (e.g. Chrome) when PresentationMode is active. - return this._getCurrentVisiblePage(); - } const views = this._scrollMode === ScrollMode.PAGE ? this.#scrollModePageState.pages