From 41be10f024e09ef3465bb9f67502be931b7fc256 Mon Sep 17 00:00:00 2001 From: Ricarda Lindner Date: Wed, 10 Jul 2019 13:59:20 +0200 Subject: [PATCH] update page number upon page changing event --- src/app/pdf-viewer/pdf-viewer.component.ts | 6 ++++++ src/app/utils/event-bus-utils.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/pdf-viewer/pdf-viewer.component.ts b/src/app/pdf-viewer/pdf-viewer.component.ts index ae67aed1f..e3cdb1e03 100644 --- a/src/app/pdf-viewer/pdf-viewer.component.ts +++ b/src/app/pdf-viewer/pdf-viewer.component.ts @@ -394,6 +394,12 @@ export class PdfViewerComponent const eventBus = createEventBus(PDFJSViewer); + eventBus.on('pagechanging', e => { + if (e.pageNumber != this._page) { + this.page = e.pageNumber; + } + }); + eventBus.on('pagerendered', e => { this.pageRendered.emit(e); }); diff --git a/src/app/utils/event-bus-utils.ts b/src/app/utils/event-bus-utils.ts index 6cbcda4e5..a051dc852 100644 --- a/src/app/utils/event-bus-utils.ts +++ b/src/app/utils/event-bus-utils.ts @@ -26,9 +26,9 @@ function attachDOMEventsToEventBus(eventBus: any) { }); evt.source.textLayerDiv.dispatchEvent(event); }); - eventBus.on('pagechange', function(evt) { + eventBus.on('pagechanging', function(evt) { const event = document.createEvent('UIEvents'); - event.initUIEvent('pagechange', true, true, window, 0); + event.initUIEvent('pagechanging', true, true, window, 0); event['pageNumber'] = evt.pageNumber; evt.source.container.dispatchEvent(event); });