Implements mouse wheel behaviour for non-Firefox browsers
This commit is contained in:
parent
c45c9a7ffa
commit
b4b145507c
@ -2049,19 +2049,22 @@ window.addEventListener('pagechange', function pagechange(evt) {
|
||||
document.getElementById('next').disabled = (page >= PDFView.pages.length);
|
||||
}, true);
|
||||
|
||||
// Firefox specific event, so that we can prevent browser from zooming
|
||||
window.addEventListener('DOMMouseScroll', function(evt) {
|
||||
if (evt.ctrlKey) {
|
||||
evt.preventDefault();
|
||||
function handleMouseWheel(evt) {
|
||||
var MOUSE_WHEEL_DELTA_FACTOR = 40;
|
||||
var ticks = (evt.type === 'DOMMouseScroll') ? -evt.detail :
|
||||
evt.wheelDelta / MOUSE_WHEEL_DELTA_FACTOR;
|
||||
var direction = (ticks < 0) ? 'zoomOut' : 'zoomIn';
|
||||
|
||||
var ticks = evt.detail;
|
||||
var direction = (ticks > 0) ? 'zoomOut' : 'zoomIn';
|
||||
if (evt.ctrlKey) { // Only zoom the pages, not the entire viewer
|
||||
evt.preventDefault();
|
||||
PDFView[direction](Math.abs(ticks));
|
||||
} else if (PresentationMode.active) {
|
||||
var FIREFOX_DELTA_FACTOR = -40;
|
||||
PDFView.mouseScroll(evt.detail * FIREFOX_DELTA_FACTOR);
|
||||
PDFView.mouseScroll(ticks * MOUSE_WHEEL_DELTA_FACTOR);
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
window.addEventListener('DOMMouseScroll', handleMouseWheel);
|
||||
window.addEventListener('mousewheel', handleMouseWheel);
|
||||
|
||||
window.addEventListener('click', function click(evt) {
|
||||
if (!PresentationMode.active) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user