The wheel event to read deltaY / deltaMode from.
Optionalelement: HTMLElement | null
Element the wheel is over, used as the page height in
DOM_DELTA_PAGE. Optional; omit it to always use the nominal height.
A pixel-equivalent vertical delta, sign preserved.
Convert a wheel event's
deltaYinto a pixel-mode-equivalent value.DOM_DELTA_PIXEL(0): returned verbatim and unclamped, so Chromium and WebKit behaviour is unchanged — no sensitivity needed re-tuning, and a fast trackpad fling (which legitimately exceeds MAX_NORMALIZED_DELTA_PX) still passes through whole. The one exception is a non-finitedeltaY(below), which is caught in every mode.DOM_DELTA_LINE(1): scaled by PIXELS_PER_LINE, then magnitude-clamped.DOM_DELTA_PAGE(2): scaled byelement.clientHeightwhen that is a positive finite number, else NOMINAL_PAGE_HEIGHT_PX, then magnitude-clamped. On any realistic canvas (clientHeight >= 200) a whole-page notch —deltaYof ±1, which is what "scroll one screen at a time" emits — saturates the cap whatever the height, so the height only shows through for a fractional page.deltaMode: returned unchanged. A future spec mode is not something we can convert, and preserving today's behaviour is the least-surprise default.A non-finite
deltaY(a driver or synthetic-event outlier) yields0in every mode, pixel included: pre-fix, a+Infinitydelta madecomputeZoomScalereturnMath.pow(0.95, Infinity) === 0and so jumped the camera 100% of its distance in one event.A zero delta of either sign returns
+0. That is contract hygiene, not a consumer requirement — consumers either branch on< 0/> 0or accumulate, and none can tell+0from-0.