web: Read WheelEvent.deltaMode before deltas.

So that Firefox doesn't switch to pixel mode for compat with other
browsers.

This should fix https://github.com/mozilla/pdf.js/issues/14476, in terms
of restoring the previous behavior.

We probably want to change the pixel-based scrolling code to not scroll
so much (the deltaMode stuff normalizes to +/-1 tick for each wheel
event, perhaps the pixel-based value should do the same).
This commit is contained in:
Emilio Cobos Álvarez 2022-01-25 18:54:21 +01:00
parent 583c39b859
commit 2f8a0638a6
No known key found for this signature in database
GPG Key ID: E1152D0994E4BF8A

View File

@ -2691,13 +2691,17 @@ function webViewerWheel(evt) {
return;
}
// It is important that we query deltaMode before delta{X,Y}, so that
// Firefox doesn't switch to DOM_DELTA_PIXEL mode for compat with other
// browsers, see https://bugzilla.mozilla.org/show_bug.cgi?id=1392460.
const deltaMode = evt.deltaMode;
const delta = normalizeWheelEventDirection(evt);
const previousScale = pdfViewer.currentScale;
const delta = normalizeWheelEventDirection(evt);
let ticks = 0;
if (
evt.deltaMode === WheelEvent.DOM_DELTA_LINE ||
evt.deltaMode === WheelEvent.DOM_DELTA_PAGE
deltaMode === WheelEvent.DOM_DELTA_LINE ||
deltaMode === WheelEvent.DOM_DELTA_PAGE
) {
// For line-based devices, use one tick per event, because different
// OSs have different defaults for the number lines. But we generally