Skip to content

galavi / normalizeWheel

Function: normalizeWheel()

normalizeWheel(event): number

Defined in: utils/input.ts:28

Normalize a WheelEvent into device-agnostic scroll "notches".

One notch ≈ one discrete mouse wheel click ≈ one trackpad scroll gesture step. Result magnitude is typically in [0.1, 3.0] per event.

Handles:

  • deltaMode (pixel / line / page)
  • macOS trackpad continuous scrolling (many small pixel deltas)
  • Windows/Linux discrete wheel (large 120px jumps)
  • High-DPI pixel scaling

Parameters

event

WheelEvent

Returns

number

Released under the GPL-3.0 License.