Element: DOMMouseScroll event - Web APIs | MDN

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js

addEventListener("DOMMouseScroll", (event) => { })

onDOMMouseScroll = (event) => { }

Event type

A WheelEvent. Inherits from MouseEvent, UIEvent and Event.

Event UIEvent MouseEvent WheelEvent

Event properties

The event has only one additional property beyond standard events.

detail

The detail property describes the scroll more precisely, with positive values indicating scrolling downward and negative values indicating scrolling upward.

If the event represents scrolling up by a page, the value of detail is -32768. If the event indicates scrolling down by a page, the value is +32768. Any other value represents the number of lines to scroll, with the direction indicated by the value's sign.

Note: Trusted events are never sent with a value of 0 for detail.

Trusted events are never fired with 0.

Note: If the platform's native mouse wheel events only provide scroll distance by pixels, or if the speed can be customized by the user, the value is computed using the line height of the nearest scrollable ancestor element of the event's target. If that element's font size is smaller than mousewheel.min_line_scroll_amount, that preference's value is used as the line height.

Browser compatibility

See also

  • MouseScrollEvent
  • Gecko's legacy pixel scroll event: MozMousePixelScroll
  • Non-Gecko browsers' legacy mouse wheel event: mousewheel
  • Standardized wheel event: wheel

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.