Remove the PresentationMode special-case from BaseViewer.update
This special-case was added because the original PresentationMode-implementation used some CSS-tricks to hide everything except the current page. With the changes in PR 14112, which added a PAGE scroll-mode, many of the old PresentationMode-specific hacks could thus be removed from both the JS and CSS code. This patch is yet another (small) clean-up step, to reduce the number of PresentationMode special-cases used throughout the `BaseViewer`. Note in particular that `BaseViewer.update` now works just fine in PresentationMode[1], and that we only need to ensure that the active page won't *accidentally* change because of the PresentationMode-specific zooming that occurs during page-switching. --- [1] In the event that we ever want to try and support spread-modes in PresentationMode, which I'm really not keen on doing since documents with varying page sizes will be annoying to handle, these changes would be necessary as well.
This commit is contained in:
parent
9a8fa3201f
commit
c91d2ac15a
@ -354,7 +354,7 @@ class BaseViewer {
|
||||
_setCurrentPageNumber(val, resetCurrentPageView = false) {
|
||||
if (this._currentPageNumber === val) {
|
||||
if (resetCurrentPageView) {
|
||||
this._resetCurrentPageView();
|
||||
this.#resetCurrentPageView();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -373,7 +373,7 @@ class BaseViewer {
|
||||
});
|
||||
|
||||
if (resetCurrentPageView) {
|
||||
this._resetCurrentPageView();
|
||||
this.#resetCurrentPageView();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -946,12 +946,11 @@ class BaseViewer {
|
||||
this.update();
|
||||
}
|
||||
|
||||
_scrollIntoView({ pageDiv, pageSpot = null, pageNumber = null }) {
|
||||
_scrollIntoView({ pageDiv, pageNumber, pageSpot = null }) {
|
||||
if (this._scrollMode === ScrollMode.PAGE) {
|
||||
if (pageNumber) {
|
||||
// Ensure that `this._currentPageNumber` is correct.
|
||||
this._setCurrentPageNumber(pageNumber);
|
||||
}
|
||||
// Ensure that `this._currentPageNumber` is correct.
|
||||
this._setCurrentPageNumber(pageNumber);
|
||||
|
||||
this.#ensurePageViewVisible();
|
||||
// Ensure that rendering always occurs, to avoid showing a blank page,
|
||||
// even if the current position doesn't change when the page is scrolled.
|
||||
@ -1122,16 +1121,17 @@ class BaseViewer {
|
||||
|
||||
/**
|
||||
* Refreshes page view: scrolls to the current page and updates the scale.
|
||||
* @private
|
||||
*/
|
||||
_resetCurrentPageView() {
|
||||
#resetCurrentPageView() {
|
||||
const pageNumber = this._currentPageNumber;
|
||||
|
||||
if (this.isInPresentationMode) {
|
||||
// Fixes the case when PDF has different page sizes.
|
||||
this._setScale(this._currentScaleValue, true);
|
||||
}
|
||||
|
||||
const pageView = this._pages[this._currentPageNumber - 1];
|
||||
this._scrollIntoView({ pageDiv: pageView.div });
|
||||
const pageView = this._pages[pageNumber - 1];
|
||||
this._scrollIntoView({ pageDiv: pageView.div, pageNumber });
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1349,28 +1349,25 @@ class BaseViewer {
|
||||
|
||||
this.renderingQueue.renderHighestPriority(visible);
|
||||
|
||||
if (!this.isInPresentationMode) {
|
||||
const isSimpleLayout =
|
||||
this._spreadMode === SpreadMode.NONE &&
|
||||
(this._scrollMode === ScrollMode.PAGE ||
|
||||
this._scrollMode === ScrollMode.VERTICAL);
|
||||
let currentId = this._currentPageNumber;
|
||||
let stillFullyVisible = false;
|
||||
const isSimpleLayout =
|
||||
this._spreadMode === SpreadMode.NONE &&
|
||||
(this._scrollMode === ScrollMode.PAGE ||
|
||||
this._scrollMode === ScrollMode.VERTICAL);
|
||||
const currentId = this._currentPageNumber;
|
||||
let stillFullyVisible = false;
|
||||
|
||||
for (const page of visiblePages) {
|
||||
if (page.percent < 100) {
|
||||
break;
|
||||
}
|
||||
if (page.id === currentId && isSimpleLayout) {
|
||||
stillFullyVisible = true;
|
||||
break;
|
||||
}
|
||||
for (const page of visiblePages) {
|
||||
if (page.percent < 100) {
|
||||
break;
|
||||
}
|
||||
if (!stillFullyVisible) {
|
||||
currentId = visiblePages[0].id;
|
||||
if (page.id === currentId && isSimpleLayout) {
|
||||
stillFullyVisible = true;
|
||||
break;
|
||||
}
|
||||
this._setCurrentPageNumber(currentId);
|
||||
}
|
||||
this._setCurrentPageNumber(
|
||||
stillFullyVisible ? currentId : visiblePages[0].id
|
||||
);
|
||||
|
||||
this._updateLocation(visible.first);
|
||||
this.eventBus.dispatch("updateviewarea", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user