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

Refactor the onBeforeDraw/onAfterDraw functionality used in BaseViewer and PDFPageView #10990

Merged

Conversation

Snuffleupagus
Copy link
Collaborator

This functionality is very old, and pre-dates e.g. the introduction of the EventBus by a number of years. Rather than attaching two callback functions to every single PDFPageView instance, it's thus now possible to utilize the EventBus such that you only need a grand total of two listeners to achieve the same result.

For the onAfterDraw callback the replacement is particularly simple, given that a 'pagerendered' event is already being dispatched in the appropriate spot. An added benefit here is the ability to remove the event listener, since we only ever care about one (arbitrary) page being rendered for the BaseViewer.onePageRendered promise.

For the onBeforeDraw callback, a new 'pagerender' event was thus added to replace the callback.

…Viewer` and `PDFPageView`

This functionality is very old, and pre-dates e.g. the introduction of the `EventBus` by a number of years. Rather than attaching two callback functions to every single `PDFPageView` instance, it's thus now possible to utilize the `EventBus` such that you only need a grand total of two listeners to achieve the same result.

For the `onAfterDraw` callback the replacement is particularly simple, given that a 'pagerendered' event is already being dispatched in the appropriate spot. An added benefit here is the ability to remove the event listener, since we only ever care about *one* (arbitrary) page being rendered for the `BaseViewer.onePageRendered` promise.

For the `onBeforeDraw` callback, a new 'pagerender' event was thus added to replace the callback.
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/3a8cd3e7f87d67c/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/3a8cd3e7f87d67c/output.txt

Total script time: 1.73 mins

Published

@timvandermeij timvandermeij merged commit b964df5 into mozilla:master Jul 19, 2019
@timvandermeij
Copy link
Contributor

Looks good! I really like the decoupling of components using the event bus.

@Snuffleupagus Snuffleupagus deleted the onBeforeDraw-onAfterDraw branch July 20, 2019 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants