mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 07:38:07 +02:00
[Firefox] Handle the user modifying the "mousewheel.with_meta.action" and "mousewheel.with_control.action" prefs (bug 1170063)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1170063. The bug only mentions the <kbd>Meta</kbd> key, but given that a similar situation can occur for <kbd>Ctrl</kbd>, it seemed reasonable to also handle that case in the same patch. The only possible caveat with the patch is that because of the use of `shadow`, things won't work perfectly if either of the prefs are changed *while* the viewer is active. In this case a reload is required in order for it to work correctly, but given that the issue this patch fixes should be quite rare anyway, that seems OK.
This commit is contained in:
parent
591a3c291f
commit
633d51fc22
2 changed files with 23 additions and 0 deletions
|
@ -394,6 +394,18 @@ var PDFViewerApplication = {
|
|||
return PDFJS.shadow(this, 'loadingBar', bar);
|
||||
},
|
||||
|
||||
get supportedMouseWheelZoomModifierKeys() {
|
||||
var support = {
|
||||
ctrlKey: true,
|
||||
metaKey: true,
|
||||
};
|
||||
//#if (FIREFOX || MOZCENTRAL)
|
||||
// support = FirefoxCom.requestSync('supportedMouseWheelZoomModifierKeys');
|
||||
//#endif
|
||||
|
||||
return PDFJS.shadow(this, 'supportedMouseWheelZoomModifierKeys', support);
|
||||
},
|
||||
|
||||
//#if (FIREFOX || MOZCENTRAL)
|
||||
initPassiveLoading: function pdfViewInitPassiveLoading() {
|
||||
function FirefoxComDataRangeTransport(length, initialData) {
|
||||
|
@ -1845,6 +1857,11 @@ function handleMouseWheel(evt) {
|
|||
PDFViewerApplication.scrollPresentationMode(ticks *
|
||||
MOUSE_WHEEL_DELTA_FACTOR);
|
||||
} else if (evt.ctrlKey || evt.metaKey) {
|
||||
var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
|
||||
if ((evt.ctrlKey && !support.ctrlKey) ||
|
||||
(evt.metaKey && !support.metaKey)) {
|
||||
return;
|
||||
}
|
||||
// Only zoom the pages, not the entire viewer.
|
||||
evt.preventDefault();
|
||||
PDFViewerApplication[direction](Math.abs(ticks));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue