Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Function normalizeWheelDelta

    • Convert a wheel event's deltaY into 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-finite deltaY (below), which is caught in every mode.
      • DOM_DELTA_LINE (1): scaled by PIXELS_PER_LINE, then magnitude-clamped.
      • DOM_DELTA_PAGE (2): scaled by element.clientHeight when that is a positive finite number, else NOMINAL_PAGE_HEIGHT_PX, then magnitude-clamped. On any realistic canvas (clientHeight >= 200) a whole-page notch — deltaY of ±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.
      • any other 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) yields 0 in every mode, pixel included: pre-fix, a +Infinity delta made computeZoomScale return Math.pow(0.95, Infinity) === 0 and 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 / > 0 or accumulate, and none can tell +0 from -0.

      Parameters

      • event: WheelEvent

        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.

      Returns number

      A pixel-equivalent vertical delta, sign preserved.