mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
[api-minor] Move the page reference/number caching into the API
Rather than having to handle this *manually* throughout the viewer, this functionality can instead be moved into the API which simplifies the code slightly.
This commit is contained in:
parent
fa69d9a3bc
commit
f6cd03955b
6 changed files with 42 additions and 74 deletions
|
@ -935,11 +935,7 @@ class PDFViewer {
|
|||
// Set the first `pdfPage` immediately, since it's already loaded,
|
||||
// rather than having to repeat the `PDFDocumentProxy.getPage` call in
|
||||
// the `this.#ensurePdfPageLoaded` method before rendering can start.
|
||||
const firstPageView = this._pages[0];
|
||||
if (firstPageView) {
|
||||
firstPageView.setPdfPage(firstPdfPage);
|
||||
this.linkService.cachePageRef(1, firstPdfPage.ref);
|
||||
}
|
||||
this._pages[0]?.setPdfPage(firstPdfPage);
|
||||
|
||||
if (this._scrollMode === ScrollMode.PAGE) {
|
||||
// Ensure that the current page becomes visible on document load.
|
||||
|
@ -994,7 +990,6 @@ class PDFViewer {
|
|||
if (!pageView.pdfPage) {
|
||||
pageView.setPdfPage(pdfPage);
|
||||
}
|
||||
this.linkService.cachePageRef(pageNum, pdfPage.ref);
|
||||
if (--getPagesLeft === 0) {
|
||||
this._pagesCapability.resolve();
|
||||
}
|
||||
|
@ -1718,9 +1713,6 @@ class PDFViewer {
|
|||
if (!pageView.pdfPage) {
|
||||
pageView.setPdfPage(pdfPage);
|
||||
}
|
||||
if (!this.linkService._cachedPageNumber?.(pdfPage.ref)) {
|
||||
this.linkService.cachePageRef(pageView.id, pdfPage.ref);
|
||||
}
|
||||
return pdfPage;
|
||||
} catch (reason) {
|
||||
console.error("Unable to get page for page view", reason);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue