Merge pull request #6207 from Snuffleupagus/viewer-remove-setScale
Remove `PDFViewerApplication.setScale` and further simplify the `scalechange` event handler (issue 6158)
This commit is contained in:
commit
76d225dd3b
@ -298,7 +298,7 @@ var PDFViewerApplication = {
|
|||||||
newScale = Math.ceil(newScale * 10) / 10;
|
newScale = Math.ceil(newScale * 10) / 10;
|
||||||
newScale = Math.min(MAX_SCALE, newScale);
|
newScale = Math.min(MAX_SCALE, newScale);
|
||||||
} while (--ticks > 0 && newScale < MAX_SCALE);
|
} while (--ticks > 0 && newScale < MAX_SCALE);
|
||||||
this.setScale(newScale, true);
|
this.pdfViewer.currentScaleValue = newScale;
|
||||||
},
|
},
|
||||||
|
|
||||||
zoomOut: function pdfViewZoomOut(ticks) {
|
zoomOut: function pdfViewZoomOut(ticks) {
|
||||||
@ -308,7 +308,7 @@ var PDFViewerApplication = {
|
|||||||
newScale = Math.floor(newScale * 10) / 10;
|
newScale = Math.floor(newScale * 10) / 10;
|
||||||
newScale = Math.max(MIN_SCALE, newScale);
|
newScale = Math.max(MIN_SCALE, newScale);
|
||||||
} while (--ticks > 0 && newScale > MIN_SCALE);
|
} while (--ticks > 0 && newScale > MIN_SCALE);
|
||||||
this.setScale(newScale, true);
|
this.pdfViewer.currentScaleValue = newScale;
|
||||||
},
|
},
|
||||||
|
|
||||||
get pagesCount() {
|
get pagesCount() {
|
||||||
@ -969,14 +969,14 @@ var PDFViewerApplication = {
|
|||||||
} else if (storedHash) {
|
} else if (storedHash) {
|
||||||
this.pdfLinkService.setHash(storedHash);
|
this.pdfLinkService.setHash(storedHash);
|
||||||
} else if (scale) {
|
} else if (scale) {
|
||||||
this.setScale(scale, true);
|
this.pdfViewer.currentScaleValue = scale;
|
||||||
this.page = 1;
|
this.page = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.pdfViewer.currentScaleValue) {
|
if (!this.pdfViewer.currentScaleValue) {
|
||||||
// Scale was not initialized: invalid bookmark or scale was not specified.
|
// Scale was not initialized: invalid bookmark or scale was not specified.
|
||||||
// Setting the default one.
|
// Setting the default one.
|
||||||
this.setScale(DEFAULT_SCALE_VALUE, true);
|
this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1172,10 +1172,6 @@ var PDFViewerApplication = {
|
|||||||
this.forceRendering();
|
this.forceRendering();
|
||||||
},
|
},
|
||||||
|
|
||||||
setScale: function (value, resetAutoSettings) {
|
|
||||||
this.pdfViewer.currentScaleValue = value;
|
|
||||||
},
|
|
||||||
|
|
||||||
rotatePages: function pdfViewRotatePages(delta) {
|
rotatePages: function pdfViewRotatePages(delta) {
|
||||||
var pageNumber = this.page;
|
var pageNumber = this.page;
|
||||||
this.pageRotation = (this.pageRotation + 360 + delta) % 360;
|
this.pageRotation = (this.pageRotation + 360 + delta) % 360;
|
||||||
@ -1443,9 +1439,8 @@ function webViewerInitialized() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('scaleSelect').addEventListener('change',
|
document.getElementById('scaleSelect').addEventListener('change', function() {
|
||||||
function() {
|
PDFViewerApplication.pdfViewer.currentScaleValue = this.value;
|
||||||
PDFViewerApplication.setScale(this.value, false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('presentationMode').addEventListener('click',
|
document.getElementById('presentationMode').addEventListener('click',
|
||||||
@ -1748,13 +1743,9 @@ window.addEventListener('scalechange', function scalechange(evt) {
|
|||||||
document.getElementById('zoomOut').disabled = (evt.scale === MIN_SCALE);
|
document.getElementById('zoomOut').disabled = (evt.scale === MIN_SCALE);
|
||||||
document.getElementById('zoomIn').disabled = (evt.scale === MAX_SCALE);
|
document.getElementById('zoomIn').disabled = (evt.scale === MAX_SCALE);
|
||||||
|
|
||||||
if (evt.presetValue) {
|
// Update the 'scaleSelect' DOM element.
|
||||||
selectScaleOption(evt.presetValue);
|
var predefinedValueFound = selectScaleOption(evt.presetValue ||
|
||||||
updateViewarea();
|
'' + evt.scale);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var predefinedValueFound = selectScaleOption('' + evt.scale);
|
|
||||||
if (!predefinedValueFound) {
|
if (!predefinedValueFound) {
|
||||||
var customScaleOption = document.getElementById('customScaleOption');
|
var customScaleOption = document.getElementById('customScaleOption');
|
||||||
var customScale = Math.round(evt.scale * 10000) / 100;
|
var customScale = Math.round(evt.scale * 10000) / 100;
|
||||||
@ -1889,7 +1880,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||||||
// keeping it unhandled (to restore page zoom to 100%)
|
// keeping it unhandled (to restore page zoom to 100%)
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
// ... and resetting the scale after browser adjusts its scale
|
// ... and resetting the scale after browser adjusts its scale
|
||||||
PDFViewerApplication.setScale(DEFAULT_SCALE_VALUE, true);
|
pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
||||||
});
|
});
|
||||||
handled = false;
|
handled = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user