Browse Source

Merge pull request #5413 from Snuffleupagus/presentationMode-no-zoom

Disable zooming in Presentation Mode
Yury Delendik 11 years ago
parent
commit
4e890b4a05
  1. 34
      web/viewer.js

34
web/viewer.js

@ -1964,11 +1964,12 @@ function handleMouseWheel(evt) {
evt.wheelDelta / MOUSE_WHEEL_DELTA_FACTOR; evt.wheelDelta / MOUSE_WHEEL_DELTA_FACTOR;
var direction = (ticks < 0) ? 'zoomOut' : 'zoomIn'; var direction = (ticks < 0) ? 'zoomOut' : 'zoomIn';
if (evt.ctrlKey) { // Only zoom the pages, not the entire viewer if (PresentationMode.active) {
evt.preventDefault(); evt.preventDefault();
PDFViewerApplication[direction](Math.abs(ticks));
} else if (PresentationMode.active) {
PDFViewerApplication.mouseScroll(ticks * MOUSE_WHEEL_DELTA_FACTOR); PDFViewerApplication.mouseScroll(ticks * MOUSE_WHEEL_DELTA_FACTOR);
} else if (evt.ctrlKey) { // Only zoom the pages, not the entire viewer
evt.preventDefault();
PDFViewerApplication[direction](Math.abs(ticks));
} }
} }
@ -2003,6 +2004,11 @@ window.addEventListener('keydown', function keydown(evt) {
// control is selected or not. // control is selected or not.
if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) { if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
// either CTRL or META key with optional SHIFT. // either CTRL or META key with optional SHIFT.
var pdfViewer = PDFViewerApplication.pdfViewer;
var inPresentationMode =
pdfViewer.presentationModeState === PresentationModeState.CHANGING ||
pdfViewer.presentationModeState === PresentationModeState.FULLSCREEN;
switch (evt.keyCode) { switch (evt.keyCode) {
case 70: // f case 70: // f
if (!PDFViewerApplication.supportsIntegratedFind) { if (!PDFViewerApplication.supportsIntegratedFind) {
@ -2021,23 +2027,29 @@ window.addEventListener('keydown', function keydown(evt) {
case 107: // FF '+' and '=' case 107: // FF '+' and '='
case 187: // Chrome '+' case 187: // Chrome '+'
case 171: // FF with German keyboard case 171: // FF with German keyboard
PDFViewerApplication.zoomIn(); if (!inPresentationMode) {
PDFViewerApplication.zoomIn();
}
handled = true; handled = true;
break; break;
case 173: // FF/Mac '-' case 173: // FF/Mac '-'
case 109: // FF '-' case 109: // FF '-'
case 189: // Chrome '-' case 189: // Chrome '-'
PDFViewerApplication.zoomOut(); if (!inPresentationMode) {
PDFViewerApplication.zoomOut();
}
handled = true; handled = true;
break; break;
case 48: // '0' case 48: // '0'
case 96: // '0' on Numpad of Swedish keyboard case 96: // '0' on Numpad of Swedish keyboard
// keeping it unhandled (to restore page zoom to 100%) if (!inPresentationMode) {
setTimeout(function () { // keeping it unhandled (to restore page zoom to 100%)
// ... and resetting the scale after browser adjusts its scale setTimeout(function () {
PDFViewerApplication.setScale(DEFAULT_SCALE, true); // ... and resetting the scale after browser adjusts its scale
}); PDFViewerApplication.setScale(DEFAULT_SCALE, true);
handled = false; });
handled = false;
}
break; break;
} }
} }

Loading…
Cancel
Save