Merge pull request #14877 from Snuffleupagus/PresentationMode-spreadMode
Add (basic) support for Spread modes in PresentationMode (issue 14749)
This commit is contained in:
commit
be67ec4a10
@ -963,10 +963,12 @@ class BaseViewer {
|
|||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
_scrollIntoView({ pageDiv, pageNumber, pageSpot = null }) {
|
#scrollIntoView(pageView, pageSpot = null) {
|
||||||
|
const { div, id } = pageView;
|
||||||
|
|
||||||
if (this._scrollMode === ScrollMode.PAGE) {
|
if (this._scrollMode === ScrollMode.PAGE) {
|
||||||
// Ensure that `this._currentPageNumber` is correct.
|
// Ensure that `this._currentPageNumber` is correct.
|
||||||
this._setCurrentPageNumber(pageNumber);
|
this._setCurrentPageNumber(id);
|
||||||
|
|
||||||
this.#ensurePageViewVisible();
|
this.#ensurePageViewVisible();
|
||||||
// Ensure that rendering always occurs, to avoid showing a blank page,
|
// Ensure that rendering always occurs, to avoid showing a blank page,
|
||||||
@ -975,8 +977,8 @@ class BaseViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!pageSpot && !this.isInPresentationMode) {
|
if (!pageSpot && !this.isInPresentationMode) {
|
||||||
const left = pageDiv.offsetLeft + pageDiv.clientLeft;
|
const left = div.offsetLeft + div.clientLeft,
|
||||||
const right = left + pageDiv.clientWidth;
|
right = left + div.clientWidth;
|
||||||
const { scrollLeft, clientWidth } = this.container;
|
const { scrollLeft, clientWidth } = this.container;
|
||||||
if (
|
if (
|
||||||
this._scrollMode === ScrollMode.HORIZONTAL ||
|
this._scrollMode === ScrollMode.HORIZONTAL ||
|
||||||
@ -986,7 +988,7 @@ class BaseViewer {
|
|||||||
pageSpot = { left: 0, top: 0 };
|
pageSpot = { left: 0, top: 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scrollIntoView(pageDiv, pageSpot);
|
scrollIntoView(div, pageSpot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1140,15 +1142,13 @@ class BaseViewer {
|
|||||||
* Refreshes page view: scrolls to the current page and updates the scale.
|
* Refreshes page view: scrolls to the current page and updates the scale.
|
||||||
*/
|
*/
|
||||||
#resetCurrentPageView() {
|
#resetCurrentPageView() {
|
||||||
const pageNumber = this._currentPageNumber;
|
const pageView = this._pages[this._currentPageNumber - 1];
|
||||||
|
|
||||||
if (this.isInPresentationMode) {
|
if (this.isInPresentationMode) {
|
||||||
// Fixes the case when PDF has different page sizes.
|
// Fixes the case when PDF has different page sizes.
|
||||||
this._setScale(this._currentScaleValue, true);
|
this._setScale(this._currentScaleValue, true);
|
||||||
}
|
}
|
||||||
|
this.#scrollIntoView(pageView);
|
||||||
const pageView = this._pages[pageNumber - 1];
|
|
||||||
this._scrollIntoView({ pageDiv: pageView.div, pageNumber });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1292,10 +1292,7 @@ class BaseViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (scale === "page-fit" && !destArray[4]) {
|
if (scale === "page-fit" && !destArray[4]) {
|
||||||
this._scrollIntoView({
|
this.#scrollIntoView(pageView);
|
||||||
pageDiv: pageView.div,
|
|
||||||
pageNumber,
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1313,11 +1310,7 @@ class BaseViewer {
|
|||||||
left = Math.max(left, 0);
|
left = Math.max(left, 0);
|
||||||
top = Math.max(top, 0);
|
top = Math.max(top, 0);
|
||||||
}
|
}
|
||||||
this._scrollIntoView({
|
this.#scrollIntoView(pageView, /* pageSpot = */ { left, top });
|
||||||
pageDiv: pageView.div,
|
|
||||||
pageSpot: { left, top },
|
|
||||||
pageNumber,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateLocation(firstPage) {
|
_updateLocation(firstPage) {
|
||||||
|
@ -78,9 +78,20 @@ class PDFPresentationMode {
|
|||||||
pageNumber: pdfViewer.currentPageNumber,
|
pageNumber: pdfViewer.currentPageNumber,
|
||||||
scaleValue: pdfViewer.currentScaleValue,
|
scaleValue: pdfViewer.currentScaleValue,
|
||||||
scrollMode: pdfViewer.scrollMode,
|
scrollMode: pdfViewer.scrollMode,
|
||||||
spreadMode: pdfViewer.spreadMode,
|
spreadMode: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (
|
||||||
|
pdfViewer.spreadMode !== SpreadMode.NONE &&
|
||||||
|
!(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes)
|
||||||
|
) {
|
||||||
|
console.warn(
|
||||||
|
"Ignoring Spread modes when entering PresentationMode, " +
|
||||||
|
"since the document may contain varying page sizes."
|
||||||
|
);
|
||||||
|
this.#args.spreadMode = pdfViewer.spreadMode;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await promise;
|
await promise;
|
||||||
return true;
|
return true;
|
||||||
@ -151,7 +162,9 @@ class PDFPresentationMode {
|
|||||||
// Presentation Mode, by waiting until fullscreen mode in enabled.
|
// Presentation Mode, by waiting until fullscreen mode in enabled.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.pdfViewer.scrollMode = ScrollMode.PAGE;
|
this.pdfViewer.scrollMode = ScrollMode.PAGE;
|
||||||
this.pdfViewer.spreadMode = SpreadMode.NONE;
|
if (this.#args.spreadMode !== null) {
|
||||||
|
this.pdfViewer.spreadMode = SpreadMode.NONE;
|
||||||
|
}
|
||||||
this.pdfViewer.currentPageNumber = this.#args.pageNumber;
|
this.pdfViewer.currentPageNumber = this.#args.pageNumber;
|
||||||
this.pdfViewer.currentScaleValue = "page-fit";
|
this.pdfViewer.currentScaleValue = "page-fit";
|
||||||
}, 0);
|
}, 0);
|
||||||
@ -177,7 +190,9 @@ class PDFPresentationMode {
|
|||||||
this.#notifyStateChange(PresentationModeState.NORMAL);
|
this.#notifyStateChange(PresentationModeState.NORMAL);
|
||||||
|
|
||||||
this.pdfViewer.scrollMode = this.#args.scrollMode;
|
this.pdfViewer.scrollMode = this.#args.scrollMode;
|
||||||
this.pdfViewer.spreadMode = this.#args.spreadMode;
|
if (this.#args.spreadMode !== null) {
|
||||||
|
this.pdfViewer.spreadMode = this.#args.spreadMode;
|
||||||
|
}
|
||||||
this.pdfViewer.currentScaleValue = this.#args.scaleValue;
|
this.pdfViewer.currentScaleValue = this.#args.scaleValue;
|
||||||
this.pdfViewer.currentPageNumber = pageNumber;
|
this.pdfViewer.currentPageNumber = pageNumber;
|
||||||
this.#args = null;
|
this.#args = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user