Merge pull request #14158 from Snuffleupagus/preRender-doc-limits
Improve pre-rendering at the start/end of the document
This commit is contained in:
commit
1ab9a6e36e
@ -1361,10 +1361,12 @@ class BaseViewer {
|
|||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#getScrollAhead(views) {
|
||||||
* @private
|
if (views.first.id === 1) {
|
||||||
*/
|
return true;
|
||||||
get _scrollAhead() {
|
} else if (views.last.id === this.pagesCount) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
switch (this._scrollMode) {
|
switch (this._scrollMode) {
|
||||||
case ScrollMode.PAGE:
|
case ScrollMode.PAGE:
|
||||||
return this._scrollModePageState.scrollDown;
|
return this._scrollModePageState.scrollDown;
|
||||||
@ -1376,7 +1378,7 @@ class BaseViewer {
|
|||||||
|
|
||||||
forceRendering(currentlyVisiblePages) {
|
forceRendering(currentlyVisiblePages) {
|
||||||
const visiblePages = currentlyVisiblePages || this._getVisiblePages();
|
const visiblePages = currentlyVisiblePages || this._getVisiblePages();
|
||||||
const scrollAhead = this._scrollAhead;
|
const scrollAhead = this.#getScrollAhead(visiblePages);
|
||||||
const preRenderExtra =
|
const preRenderExtra =
|
||||||
this._spreadMode !== SpreadMode.NONE &&
|
this._spreadMode !== SpreadMode.NONE &&
|
||||||
this._scrollMode !== ScrollMode.HORIZONTAL;
|
this._scrollMode !== ScrollMode.HORIZONTAL;
|
||||||
|
@ -82,10 +82,11 @@ class PDFRenderingQueue {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// No pages needed rendering, so check thumbnails.
|
// No pages needed rendering, so check thumbnails.
|
||||||
if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
|
if (
|
||||||
if (this.pdfThumbnailViewer.forceRendering()) {
|
this.isThumbnailViewEnabled &&
|
||||||
return;
|
this.pdfThumbnailViewer?.forceRendering()
|
||||||
}
|
) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.printing) {
|
if (this.printing) {
|
||||||
@ -132,7 +133,7 @@ class PDFRenderingQueue {
|
|||||||
// All the visible views have rendered; try to handle any "holes" in the
|
// All the visible views have rendered; try to handle any "holes" in the
|
||||||
// page layout (can happen e.g. with spreadModes at higher zoom levels).
|
// page layout (can happen e.g. with spreadModes at higher zoom levels).
|
||||||
if (lastId - firstId > 1) {
|
if (lastId - firstId > 1) {
|
||||||
for (let i = 0, ii = lastId - firstId; i <= ii; i++) {
|
for (let i = 1, ii = lastId - firstId; i < ii; i++) {
|
||||||
const holeId = scrolledDown ? firstId + i : lastId - i,
|
const holeId = scrolledDown ? firstId + i : lastId - i,
|
||||||
holeView = views[holeId - 1];
|
holeView = views[holeId - 1];
|
||||||
if (!this.isViewFinished(holeView)) {
|
if (!this.isViewFinished(holeView)) {
|
||||||
|
@ -295,12 +295,22 @@ class PDFThumbnailViewer {
|
|||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#getScrollAhead(views) {
|
||||||
|
if (views.first.id === 1) {
|
||||||
|
return true;
|
||||||
|
} else if (views.last.id === this._thumbnails.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return this.scroll.down;
|
||||||
|
}
|
||||||
|
|
||||||
forceRendering() {
|
forceRendering() {
|
||||||
const visibleThumbs = this._getVisibleThumbs();
|
const visibleThumbs = this._getVisibleThumbs();
|
||||||
|
const scrollAhead = this.#getScrollAhead(visibleThumbs);
|
||||||
const thumbView = this.renderingQueue.getHighestPriority(
|
const thumbView = this.renderingQueue.getHighestPriority(
|
||||||
visibleThumbs,
|
visibleThumbs,
|
||||||
this._thumbnails,
|
this._thumbnails,
|
||||||
this.scroll.down
|
scrollAhead
|
||||||
);
|
);
|
||||||
if (thumbView) {
|
if (thumbView) {
|
||||||
this._ensurePdfPageLoaded(thumbView).then(() => {
|
this._ensurePdfPageLoaded(thumbView).then(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user