Skip to content

Commit

Permalink
fixup! Events
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Dec 11, 2024
1 parent 0ced0a4 commit e3a82cb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
8 changes: 4 additions & 4 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2280,18 +2280,18 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
};
}

function onPageRender({ pageNumber, source }) {
function onPageRender({ pageNumber }) {
// If the page is (the most) visible when it starts rendering,
// ensure that the page number input loading indicator is displayed.
if (pageNumber === this.page && !source.detailView) {
if (pageNumber === this.page) {
this.toolbar?.updateLoadingIndicatorState(true);
}
}

function onPageRendered({ pageNumber, source, error }) {
function onPageRendered({ pageNumber, error }) {
// If the page is still visible when it has finished rendering,
// ensure that the page number input loading indicator is hidden.
if (pageNumber === this.page && !source.detailView) {
if (pageNumber === this.page) {
this.toolbar?.updateLoadingIndicatorState(false);
}

Expand Down
32 changes: 24 additions & 8 deletions web/pdf_page_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1176,13 +1176,20 @@ class PDFPageView extends PDFPageViewBase {
this.#useThumbnailCanvas.regularAnnotations =
!renderTask.separateAnnots;

this.eventBus.dispatch("pagerendered", {
source: this,
pageNumber: this.id,
cssTransform: false,
timestamp: performance.now(),
error: this._renderError,
});
// If there is a `.detailView` that still needs to be rendered, it will
// dispatch the pagerendered event once it's done.
if (
!this.detailView ||
this.detailView.renderingState === RenderingStates.FINISHED
) {
this.eventBus.dispatch("pagerendered", {
source: this,
pageNumber: this.id,
cssTransform: false,
timestamp: performance.now(),
error: this._renderError,
});
}
}
).then(async () => {
this.structTreeLayer ||= new StructTreeLayerBuilder(
Expand Down Expand Up @@ -1474,7 +1481,16 @@ class PDFPageDetailView extends PDFPageViewBase {
viewport,
pageColors: this.pageColors,
},
prevCanvas
prevCanvas,
() => {
this.eventBus.dispatch("pagerendered", {
source: this,
pageNumber: this.id,
cssTransform: false,
timestamp: performance.now(),
error: this._renderError,
});
}
);

div.setAttribute("data-loaded", true);
Expand Down

0 comments on commit e3a82cb

Please sign in to comment.