• Web APIs
  • ariaAtomic
  • ariaBusy
  • ariaColIndexText
  • ariaDisabled
  • ariaKeyShortcuts
  • ariaModal
  • ariaPlaceholder
  • ariaRelevant Non-standard
  • ariaRowIndex
  • ariaSetSize
  • ariaValueNow
  • childElementCount
  • clientHeight
  • currentCSSZoom
  • elementTiming Experimental
  • lastElementChild
  • outerHTML
  • scrollHeight
  • scrollLeftMax Non-standard
  • scrollTopMax Non-standard
  • tagName
  • Instance methods
    1. attachShadow()
    2. computedStyleMap()
    3. getAttributeNode()
    4. getClientRects()
    5. getHTML()
    6. hasPointerCapture()
    7. matches()
    8. releasePointerCapture()
    9. removeAttributeNS()
    10. requestPointerLock()
    11. scrollIntoViewIfNeeded() Non-standard
    12. setAttributeNodeNS()
    13. setCapture() Non-standard Deprecated
    14. afterscriptexecute Non-standard Deprecated
    15. animationstart
    16. beforematch Experimental
    17. beforescriptexecute Non-standard Deprecated
    18. beforexrselect Experimental
    19. compositionstart
    20. copy
    21. DOMActivate Deprecated
    22. DOMMouseScroll Non-standard Deprecated
    23. fullscreenchange
    24. gesturechange Non-standard
    25. gestureend Non-standard
    26. gesturestart Non-standard
    27. keypress Deprecated
    28. mouseenter
    29. mouseover
    30. mousewheel Non-standard Deprecated
    31. MozMousePixelScroll Non-standard Deprecated
    32. pointerenter
    33. pointerover
    34. pointerrawupdate Experimental
    35. scrollsnapchange Experimental
    36. scrollsnapchanging Experimental
    37. touchmove
    38. transitionrun
    39. webkitmouseforcechanged Non-standard
    40. webkitmouseforcedown Non-standard
    41. webkitmouseforceup Non-standard
    42. webkitmouseforcewillbegin Non-standard
    43. Learn more
    44. See full compatibility
  • The wheel event fires when the user rotates a wheel button on a pointing device (typically a mouse). It is also fired for related devices that simulate wheel actions, such as trackpads and mouse balls.

    This event replaces the non-standard deprecated mousewheel event.

    Don't confuse the wheel event with the scroll event:

    • A wheel event doesn't necessarily dispatch a scroll event. For example, the element may be unscrollable at all. Zooming actions using the wheel or trackpad also fire wheel events.
    • A scroll event isn't necessarily triggered by a wheel event. Elements can also be scrolled by using the keyboard, dragging a scrollbar, or using JavaScript.
    • Even when the wheel event does trigger scrolling, the delta* values in the wheel event don't necessarily reflect the content's scrolling direction.

    Therefore, do not rely on the wheel event's delta* properties to get the scrolling direction. Instead, detect value changes of scrollTop of the target in the scroll event.

    The wheel event is cancelable. If the event is canceled, no scrolling or zooming is performed. This may cause performance issues as the browser has to wait for every wheel event to be processed before actually scrolling the content. You can avoid this by setting passive: true when calling addEventListener(), or set an event handler property.

    js
    addEventListener("wheel", (event) => {});
    
    onwheel = (event) => {};
    

    Event type

    Event properties

    This interface inherits properties from its ancestors, Event.

    WheelEvent.deltaX Read only

    Returns a double representing the horizontal scroll amount.

    WheelEvent.deltaY Read only

    Returns a double representing the vertical scroll amount.

    WheelEvent.deltaZ Read only

    Returns a double representing the scroll amount for the z-axis.

    WheelEvent.deltaMode Read only

    Returns an unsigned long representing the unit of the delta* values' scroll amount. Permitted values are:

    Constant Value Description
    WheelEvent.DOM_DELTA_PIXEL 0x00 The delta* values are specified in pixels.
    WheelEvent.DOM_DELTA_LINE 0x01 The delta* values are specified in lines. Each mouse click scrolls a line of content, where the method used to calculate line height is browser dependent.
    WheelEvent.DOM_DELTA_PAGE 0x02 The delta* values are specified in pages. Each mouse click scrolls a page of content.
    WheelEvent.wheelDelta Read only Deprecated

    Returns an integer (32-bit) representing the distance in pixels.

    WheelEvent.wheelDeltaX Read only Deprecated

    Returns an integer representing the horizontal scroll amount.

    WheelEvent.wheelDeltaY Read only Deprecated

    Returns an integer representing the vertical scroll amount.

    Examples

    Scaling an element via the wheel

    This example shows how to scale an element using the mouse (or other pointing device) wheel.

    html
    <div>Scale me with your mouse wheel.</div>
    
    css
    body {
      min-height: 100vh;
      margin: 0;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    
    div {
      width: 105px;
      height: 105px;
      background: #cdf;
      padding: 5px;
    }
    
    js
    function zoom(event) {
      event.preventDefault();
    
      scale += event.deltaY * -0.01;
    
      / Restrict scale
      scale = Math.min(Math.max(0.125, scale), 4);
    
      / Apply scale transform
      el.style.transform = `scale(${scale})`;
    }
    
    let scale = 1;
    const el = document.querySelector("div");
    el.onwheel = zoom;