From a1f4bff4f38b92df34ede30a5cbb3f54f39ee5ad Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 15 Oct 2014 22:03:13 +0200 Subject: [PATCH] Disable zooming in Presentation Mode --- web/viewer.js | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/web/viewer.js b/web/viewer.js index 95614693d..3a86c3dcf 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -1964,11 +1964,12 @@ function handleMouseWheel(evt) { evt.wheelDelta / MOUSE_WHEEL_DELTA_FACTOR; var direction = (ticks < 0) ? 'zoomOut' : 'zoomIn'; - if (evt.ctrlKey) { // Only zoom the pages, not the entire viewer + if (PresentationMode.active) { + evt.preventDefault(); + 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)); - } else if (PresentationMode.active) { - PDFViewerApplication.mouseScroll(ticks * MOUSE_WHEEL_DELTA_FACTOR); } } @@ -2003,6 +2004,11 @@ window.addEventListener('keydown', function keydown(evt) { // control is selected or not. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) { // 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) { case 70: // f if (!PDFViewerApplication.supportsIntegratedFind) { @@ -2021,23 +2027,29 @@ window.addEventListener('keydown', function keydown(evt) { case 107: // FF '+' and '=' case 187: // Chrome '+' case 171: // FF with German keyboard - PDFViewerApplication.zoomIn(); + if (!inPresentationMode) { + PDFViewerApplication.zoomIn(); + } handled = true; break; case 173: // FF/Mac '-' case 109: // FF '-' case 189: // Chrome '-' - PDFViewerApplication.zoomOut(); + if (!inPresentationMode) { + PDFViewerApplication.zoomOut(); + } handled = true; break; case 48: // '0' case 96: // '0' on Numpad of Swedish keyboard - // keeping it unhandled (to restore page zoom to 100%) - setTimeout(function () { - // ... and resetting the scale after browser adjusts its scale - PDFViewerApplication.setScale(DEFAULT_SCALE, true); - }); - handled = false; + if (!inPresentationMode) { + // keeping it unhandled (to restore page zoom to 100%) + setTimeout(function () { + // ... and resetting the scale after browser adjusts its scale + PDFViewerApplication.setScale(DEFAULT_SCALE, true); + }); + handled = false; + } break; } }