Merge pull request #15959 from Snuffleupagus/normalizeWheelEventDelta-tweaks

Tweak the `normalizeWheelEventDelta` helper function
This commit is contained in:
Jonas Jenwald 2023-01-25 11:13:50 +01:00 committed by GitHub
commit ce941255e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -622,17 +622,16 @@ function normalizeWheelEventDirection(evt) {
}
function normalizeWheelEventDelta(evt) {
const deltaMode = evt.deltaMode; // Avoid being affected by bug 1392460.
let delta = normalizeWheelEventDirection(evt);
const MOUSE_DOM_DELTA_PIXEL_MODE = 0;
const MOUSE_DOM_DELTA_LINE_MODE = 1;
const MOUSE_PIXELS_PER_LINE = 30;
const MOUSE_LINES_PER_PAGE = 30;
// Converts delta to per-page units
if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
if (deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
} else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
} else if (deltaMode === WheelEvent.DOM_DELTA_LINE) {
delta /= MOUSE_LINES_PER_PAGE;
}
return delta;