Skip to content

Commit 0766898

Browse files
Merge pull request #15720 from Snuffleupagus/issue-15695
Ensure that the initial document position is always correct with non-default Scroll/Spread modes (issue 15695)
2 parents 4f1b6f3 + 37c2408 commit 0766898

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

web/pdf_viewer.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,10 +1023,12 @@ class PDFViewer {
10231023
#scrollIntoView(pageView, pageSpot = null) {
10241024
const { div, id } = pageView;
10251025

1026-
if (this._scrollMode === ScrollMode.PAGE) {
1027-
// Ensure that `this._currentPageNumber` is correct.
1026+
// Ensure that `this._currentPageNumber` is correct, when `#scrollIntoView`
1027+
// is called directly (and not from `#resetCurrentPageView`).
1028+
if (this._currentPageNumber !== id) {
10281029
this._setCurrentPageNumber(id);
1029-
1030+
}
1031+
if (this._scrollMode === ScrollMode.PAGE) {
10301032
this.#ensurePageViewVisible();
10311033
// Ensure that rendering always occurs, to avoid showing a blank page,
10321034
// even if the current position doesn't change when the page is scrolled.
@@ -1046,6 +1048,15 @@ class PDFViewer {
10461048
}
10471049
}
10481050
scrollIntoView(div, pageSpot);
1051+
1052+
// Ensure that the correct *initial* document position is set, when any
1053+
// OpenParameters are used, for documents with non-default Scroll/Spread
1054+
// modes (fixes issue 15695). This is necessary since the scroll-handler
1055+
// invokes the `update`-method asynchronously, and `this._location` could
1056+
// thus be wrong when the initial zooming occurs in the default viewer.
1057+
if (!this._currentScaleValue && this._location) {
1058+
this._location = null;
1059+
}
10491060
}
10501061

10511062
/**

0 commit comments

Comments
 (0)