-
Notifications
You must be signed in to change notification settings - Fork 116
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
Fix: Chrome Print Preview Fix #1030
Conversation
Verified that @mickr has signed the CLA. Thanks for the pull request! |
src/lib/viewers/image/ImageViewer.js
Outdated
} else { | ||
this.printframe.contentWindow.print(); | ||
// Chrome will show preview from iframe before the content is loaded. | ||
this.printframe.addEventListener('load', defaultPrintHandler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can there be a situation where the frame has already fired its load
event by the time this code executes? Such as if the content is cached? If so, does print still work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is from a few years ago, but I wonder if we could streamline the code to wait for the 'load' event for all browsers before attempting the print?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am updating the code as @ConradJChan suggested for all browsers.
065a5e5
to
724242b
Compare
* Add listener that is fired once the iframe has loaded it's content for printing. This enables chrome to show an accurate print preview.
Refactor code so that all print calls are async on the load event and the event handler is added earlier in the instantiation process.
6e18ab1
to
197815b
Compare
This enables chrome to show an accurate print preview.