From 96eaa7b9578acc882dbf1f33a370c4572cf63a1a Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Thu, 29 Aug 2024 20:55:56 +0300 Subject: [PATCH] Fix thumbnails view lazy rendering Fixes zotero/zotero#4643 --- src/common/components/sidebar/thumbnails-view.js | 2 +- src/pdf/pdf-thumbnails.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/components/sidebar/thumbnails-view.js b/src/common/components/sidebar/thumbnails-view.js index 9516a474..6b5ef3dd 100644 --- a/src/common/components/sidebar/thumbnails-view.js +++ b/src/common/components/sidebar/thumbnails-view.js @@ -53,7 +53,7 @@ function ThumbnailsView(props) { useEffect (() => { let options = { - root: containerRef.current, + root: document.querySelector('.sidebar-content'), rootMargin: "200px", threshold: 1.0 }; diff --git a/src/pdf/pdf-thumbnails.js b/src/pdf/pdf-thumbnails.js index cde04ccb..4bdc9d47 100644 --- a/src/pdf/pdf-thumbnails.js +++ b/src/pdf/pdf-thumbnails.js @@ -221,6 +221,12 @@ class PDFThumbnails { } async render(pageIndexes = [], rerenderOnly) { + // If there are no thumbnails being rerendered due to annotation changes, + // clear the rendering queue to only render the thumbnails that were recently + // scrolled into view in the sidebar thumbnails view + if (!this._thumbnails.some(x => x.forceRerender)) { + this._renderQueue.end(); + } for (let pageIndex of pageIndexes) { let thumbnail = this._thumbnails[pageIndex]; // Only already rendered thumbnails will be re-rendered, which means