Skip to content

Commit

Permalink
Fix waiting for PDF to load
Browse files Browse the repository at this point in the history
  • Loading branch information
robertknight committed Oct 9, 2020
1 parent 150e15b commit 7d0f474
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/annotator/anchoring/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ async function getPageView(pageIndex) {
// a "pdfPage" property.
pageView = await new Promise(resolve => {
const onPagesLoaded = () => {
document.removeEventListener('pagesloaded', onPagesLoaded);
pdfViewer.eventBus.off('pagesloaded', onPagesLoaded);
resolve(pdfViewer.getPageView(pageIndex));
};
document.addEventListener('pagesloaded', onPagesLoaded);
pdfViewer.eventBus.on('pagesloaded', onPagesLoaded);
});
}

Expand Down
1 change: 1 addition & 0 deletions src/types/pdfjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
* Defined in `web/pdf_viewer.js` in the PDF.js source.
*
* @prop {number} pagesCount
* @prop {EventBus} eventBus - Reference to the global event bus
* @prop {(page: number) => PDFPageView|null} getPageView
*/

Expand Down

0 comments on commit 7d0f474

Please sign in to comment.