Prevent documents from intermittently opening with the zoom level set to 1% (issue 6253)
*This fixes a regression from PR 6192.* Under some circumstances, the `resize` event handler in `viewer.js` is fired before the scale has been set. This can lead to PDF documents being rendered at the wrong zoom level when they are opened. It seems that a way to reliably trigger this is to, using the Firefox addon, open a PDF file that triggers the `fallback` bar, in a new background tab (i.e. middle clicking on a link, or use the context menu). Prior to PR 6192, we checked the selected option in the `scaleSelect` dropdown instead. Since `pageAutoOption` is selected by default in `viewer.html`, this should explain why the issue wasn't visible previously.
This commit is contained in:
parent
862342189f
commit
299d05eaa5
@ -1639,13 +1639,16 @@ window.addEventListener('updateviewarea', function (evt) {
|
||||
window.addEventListener('resize', function webViewerResize(evt) {
|
||||
if (PDFViewerApplication.initialized) {
|
||||
var currentScaleValue = PDFViewerApplication.pdfViewer.currentScaleValue;
|
||||
switch (currentScaleValue) {
|
||||
case 'auto':
|
||||
case 'page-fit':
|
||||
case 'page-width':
|
||||
// Note: the scale is constant for 'page-actual'.
|
||||
PDFViewerApplication.pdfViewer.currentScaleValue = currentScaleValue;
|
||||
break;
|
||||
if (currentScaleValue === 'auto' ||
|
||||
currentScaleValue === 'page-fit' ||
|
||||
currentScaleValue === 'page-width') {
|
||||
// Note: the scale is constant for 'page-actual'.
|
||||
PDFViewerApplication.pdfViewer.currentScaleValue = currentScaleValue;
|
||||
} else if (!currentScaleValue) {
|
||||
// Normally this shouldn't happen, but if the scale wasn't initialized
|
||||
// we set it to the default value in order to prevent any issues.
|
||||
// (E.g. the document being rendered with the wrong scale on load.)
|
||||
PDFViewerApplication.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
||||
}
|
||||
}
|
||||
updateViewarea();
|
||||
|
Loading…
x
Reference in New Issue
Block a user