This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

deltaY

Summary

Gets the distance that a mouse wheel has rotated around the y-axis (vertical).

Property of dom/WheelEventdom/WheelEvent

Syntax

Note: This property is read-only.

var deltaY = event.deltaY;

Return Value

Returns an object of type NumberNumber

The Y rotation distance in pixels, lines or pages.

Examples

The following example shows how to determine the deltaY property of the WheelEvent. Note: to feature test for deltaY you need to use the ‘deltaY’ in event as deltaY may have a value of 0 (false)… (event.deltaY) can return false negatives.

<script type="text/javascript">
function getDeltaMode(dMode){
    switch (dMode){
        case WheelEvent.DOM_DELTA_LINE:// 1
            return 'DOM_DELTA_LINE (1)';
        case WheelEvent.DOM_DELTA_PAGE:// 2
            return 'DOM_DELTA_PAGE (2)';
        case WheelEvent.DOM_DELTA_PIXEL:// 0
            return 'DOM_DELTA_PIXEL (0)';
        default:
            return 'Unknown DeltaMode:' + dMode;

    }
}
   function showWheelEvent(evt){
        if(!evt)evt=window.event;
        theform=document.forms.frmEvent;
        if(evt.type=='wheel'){
            theform.deltamode.value=('deltaMode' in evt)?getDeltaMode(evt.deltaMode):'N/A';
            theform.deltax.value=('deltaX' in evt)?evt.deltaX:'N/A';
            theform.deltay.value=('deltaY' in evt)?evt.deltaY:'N/A';
            theform.deltaz.value=('deltaZ' in evt)?evt.deltaZ:'N/A';
        }

   }
</script>

Notes

The measurement of the distance can be determined using the deltaMode property.

Related specifications

DOM Level 3 Events
Working Draft

Attributions