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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
get _scrollAhead() {
|
||||
#getScrollAhead(views) {
|
||||
if (views.first.id === 1) {
|
||||
return true;
|
||||
} else if (views.last.id === this.pagesCount) {
|
||||
return false;
|
||||
}
|
||||
switch (this._scrollMode) {
|
||||
case ScrollMode.PAGE:
|
||||
return this._scrollModePageState.scrollDown;
|
||||
@ -1376,7 +1378,7 @@ class BaseViewer {
|
||||
|
||||
forceRendering(currentlyVisiblePages) {
|
||||
const visiblePages = currentlyVisiblePages || this._getVisiblePages();
|
||||
const scrollAhead = this._scrollAhead;
|
||||
const scrollAhead = this.#getScrollAhead(visiblePages);
|
||||
const preRenderExtra =
|
||||
this._spreadMode !== SpreadMode.NONE &&
|
||||
this._scrollMode !== ScrollMode.HORIZONTAL;
|
||||
|
@ -82,10 +82,11 @@ class PDFRenderingQueue {
|
||||
return;
|
||||
}
|
||||
// No pages needed rendering, so check thumbnails.
|
||||
if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
|
||||
if (this.pdfThumbnailViewer.forceRendering()) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
this.isThumbnailViewEnabled &&
|
||||
this.pdfThumbnailViewer?.forceRendering()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.printing) {
|
||||
@ -132,7 +133,7 @@ class PDFRenderingQueue {
|
||||
// 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).
|
||||
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,
|
||||
holeView = views[holeId - 1];
|
||||
if (!this.isViewFinished(holeView)) {
|
||||
|
@ -295,12 +295,22 @@ class PDFThumbnailViewer {
|
||||
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() {
|
||||
const visibleThumbs = this._getVisibleThumbs();
|
||||
const scrollAhead = this.#getScrollAhead(visibleThumbs);
|
||||
const thumbView = this.renderingQueue.getHighestPriority(
|
||||
visibleThumbs,
|
||||
this._thumbnails,
|
||||
this.scroll.down
|
||||
scrollAhead
|
||||
);
|
||||
if (thumbView) {
|
||||
this._ensurePdfPageLoaded(thumbView).then(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user