Skip to content

Commit

Permalink
Only subscribe on first time
Browse files Browse the repository at this point in the history
  • Loading branch information
shamoon committed Oct 31, 2024
1 parent 382be39 commit d1c4b06
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/app/pdf-viewer/pdf-viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export class PdfViewerComponent
private isInitialized = false;
private loadingTask?: PDFDocumentLoadingTask | null;
private destroy$ = new Subject<void>();
private awaitingInit: boolean = false;

@Output('after-load-complete') afterLoadComplete = new EventEmitter<PDFDocumentProxy>();
@Output('page-rendered') pageRendered = new EventEmitter<CustomEvent>();
Expand Down Expand Up @@ -570,8 +571,9 @@ export class PdfViewerComponent
});
}

if (!this.pdfViewer._pages?.length) {
if (!this.pdfViewer._pages?.length && !this.awaitingInit) {
// the first time we wait until pages init
this.awaitingInit = true;
this.pageInitialized.subscribe(() => {
this.updateSize();
})
Expand Down

0 comments on commit d1c4b06

Please sign in to comment.