Skip to content

Commit

Permalink
Merge pull request #6192 from Snuffleupagus/viewer-resize-update-scale
Browse files Browse the repository at this point in the history
Refactor the 'resize' event handler in viewer.js (issue 6158)
  • Loading branch information
timvandermeij committed Jul 10, 2015
2 parents ccfafea + 35ee1e1 commit c9b6b69
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions web/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1643,13 +1643,16 @@ window.addEventListener('updateviewarea', function (evt) {
}, true);

window.addEventListener('resize', function webViewerResize(evt) {
if (PDFViewerApplication.initialized &&
(document.getElementById('pageAutoOption').selected ||
/* Note: the scale is constant for |pageActualOption|. */
document.getElementById('pageFitOption').selected ||
document.getElementById('pageWidthOption').selected)) {
var selectedScale = document.getElementById('scaleSelect').value;
PDFViewerApplication.setScale(selectedScale, false);
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;
}
}
updateViewarea();

Expand Down Expand Up @@ -1707,7 +1710,7 @@ window.addEventListener('change', function webViewerChange(evt) {
function selectScaleOption(value) {
var options = document.getElementById('scaleSelect').options;
var predefinedValueFound = false;
for (var i = 0; i < options.length; i++) {
for (var i = 0, ii = options.length; i < ii; i++) {
var option = options[i];
if (option.value !== value) {
option.selected = false;
Expand Down

0 comments on commit c9b6b69

Please sign in to comment.