diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index 234f71ba8..e5f1e7eb0 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -125,6 +125,7 @@ class PDFPageView { #textLayerMode = TextLayerMode.ENABLE; #useThumbnailCanvas = { + directDrawing: true, initialOptionalContent: true, regularAnnotations: true, }; @@ -552,6 +553,7 @@ class PDFPageView { optionalContentConfig.hasInitialVisibility; }); } + this.#useThumbnailCanvas.directDrawing = true; const totalRotation = (this.rotation + this.pdfPageRotate) % 360; this.viewport = this.viewport.clone({ @@ -605,6 +607,9 @@ class PDFPageView { // the rendering state to INITIAL, hence the next call to // PDFViewer.update() will trigger a redraw (if it's mandatory). this.renderingState = RenderingStates.FINISHED; + // Ensure that the thumbnails won't become partially (or fully) blank, + // if the sidebar is opened before the actual rendering is done. + this.#useThumbnailCanvas.directDrawing = false; } this.cssTransform({ @@ -616,6 +621,11 @@ class PDFPageView { hideTextLayer: postponeDrawing, }); + if (postponeDrawing) { + // The "pagerendered"-event will be dispatched once the actual + // rendering is done, hence don't dispatch it here as well. + return; + } this.eventBus.dispatch("pagerendered", { source: this, pageNumber: this.id, @@ -1028,9 +1038,11 @@ class PDFPageView { * @ignore */ get thumbnailCanvas() { - const { initialOptionalContent, regularAnnotations } = + const { directDrawing, initialOptionalContent, regularAnnotations } = this.#useThumbnailCanvas; - return initialOptionalContent && regularAnnotations ? this.canvas : null; + return directDrawing && initialOptionalContent && regularAnnotations + ? this.canvas + : null; } }