Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 408 - Needs further edits #420

Merged
merged 2 commits into from
Dec 8, 2018
Merged

Conversation

ColinT
Copy link
Contributor

@ColinT ColinT commented Dec 8, 2018

This PR addresses #408

The current method of listening to the pagerendered event using @HostListener no longer works. This is because PDFSinglePageViewer now loads one page ahead of the current page. Since the event.source.div is not yet in the DOM, the @HostListener fails.

// utils/event-bus-utils.ts:20
// ...
evt.source.div.dispatchEvent(event); // <-- this fires properly but the HostListener does not receive the dispatched event
// ...

One solution to this is to listen to the eventBus from createEventBus directly in both setupMultipageViewer() and setupSinglePageViewer():

// pdf-viewer.component.ts
const eventBus = createEventBus(PDFJSViewer);

eventBus.on('pagerendered', (e) => {
    this.pageRendered.emit(e);
});

This approach is very different from the current setup, and I am not sure what side effects it may cause. But it is the way recommended by the pdf.js devs: #10230.

@VadimDez VadimDez added this to the 5.2.4 milestone Dec 8, 2018
@VadimDez VadimDez merged commit acd7ccc into VadimDez:master Dec 8, 2018
Copy link

@sChupin sChupin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You left some commented code in the PR.
Also, you did not apply similar changes to the 'textlayerrendered' event.
I will create another PR to fix that when I find the time to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants