mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Let getVisibleElements
return a Set containing the visible element id
s
Note how in `PDFPageViewBuffer.resize` we're manually iterating through the visible pages in order to build a Set of the visible page `id`s. By instead moving the building of this Set into the `getVisibleElements` helper function, as part of the existing parsing, this code becomes *ever so slightly* more efficient. Furthermore, more direct access to the visible page `id`s also come in handy in other parts of the viewer as well. In the `BaseViewer.isPageVisible` method we no longer need to loop through the visible pages, but can instead directly check if the pageNumber is visible. In the `PDFRenderingQueue.getHighestPriority` method, when checking for "holes" in the page layout, we can also avoid some unnecessary look-ups this way.
This commit is contained in:
parent
2ac6c939a5
commit
6323f8532a
4 changed files with 30 additions and 26 deletions
|
@ -133,9 +133,13 @@ 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 > numVisible) {
|
||||
const visibleIds = visible.ids;
|
||||
for (let i = 1, ii = lastId - firstId; i < ii; i++) {
|
||||
const holeId = scrolledDown ? firstId + i : lastId - i,
|
||||
holeView = views[holeId - 1];
|
||||
const holeId = scrolledDown ? firstId + i : lastId - i;
|
||||
if (visibleIds.has(holeId)) {
|
||||
continue;
|
||||
}
|
||||
const holeView = views[holeId - 1];
|
||||
if (!this.isViewFinished(holeView)) {
|
||||
return holeView;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue