mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Slightly improve the BaseViewer.{firstPagePromise, onePageRendered, pagesPromise}
functionality
There's a couple of issues with this functionality: - The respective `PromiseCapability` instances are not being reset, in `BaseViewer._resetView`, when the document is closed which is inconsistent with all other state. - While the default viewer depends on these promises, and they thus ought to be considered part of e.g. the `PDFViewer` API-surface, they're not really defined in a particularily user-visible way (being that they're attached to the `BaseViewer` instance *inline* in `BaseViewer.setDocument`). - There's some internal `BaseViewer` state, e.g. `BaseViewer._pageViewsReady`, which is tracked manually and could instead be tracked indirectly via the relevant `PromiseCapability`, thus reducing the need to track state *twice* since that's always best to avoid. *Please note:* In the existing implementation, these promises are not defined *until* the `BaseViewer.setDocument` method has been called. While it would've been simple to lift that restriction in this patch, I'm purposely choosing *not* to do so since this ensures that any Promise handlers added inside of `BaseViewer.setDocument` are always invoked *before* any external ones (and keeping that behaviour seems generally reasonable).
This commit is contained in:
parent
7b07b88e71
commit
1fac29d184
2 changed files with 32 additions and 24 deletions
|
@ -1057,9 +1057,7 @@ const PDFViewerApplication = {
|
|||
|
||||
const pdfViewer = this.pdfViewer;
|
||||
pdfViewer.setDocument(pdfDocument);
|
||||
const firstPagePromise = pdfViewer.firstPagePromise;
|
||||
const pagesPromise = pdfViewer.pagesPromise;
|
||||
const onePageRendered = pdfViewer.onePageRendered;
|
||||
const { firstPagePromise, onePageRendered, pagesPromise } = pdfViewer;
|
||||
|
||||
const pdfThumbnailViewer = this.pdfThumbnailViewer;
|
||||
pdfThumbnailViewer.setDocument(pdfDocument);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue